Home get previously submitted `post` data after switching to another razor view asp.net
Reply: 1

get previously submitted `post` data after switching to another razor view asp.net

Faadil Farick
1#
Faadil Farick Published in 2017-12-05 01:47:23Z

I'm submitting data of an advertisement to the particular controller action method of it. Then I need to redirect user to the payment page to carry out the payment details. Then I need to save the advertisement details. But after i switch to the payments page previously submitted advertisement details are lost and returns null when trying to save it to database

Posting Business details and redirecting to payments page as below

<div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Submit" formaction="@Url.Action("Index", "Paypal")" class="btn btn-default" />
        </div>
    </div>

Then user will be redirect to the payments page

public ActionResult Index()
    {
        return View();
    }

and if payment is done should save the previously submitted data to db

<div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Submit" formaction="@Url.Action("PaymentWithCreditCard", "Paypal")" class="btn btn-default" />
        </div>
    </div>

The PaymentWithCreditCard is as below

public ActionResult PaymentWithCreditCard([Bind(Include = "ID,ItemName,ItemPrice,ItemQuantity,cvv,month,year,fname,lname,cardnumber,cardtype,fee,Subtotal,Total,Shipping,Tax")]
    Paymentinfo paymentinfo, [Bind(Include = "ID,Title,Address,Category,Description,Latitude,Longitute,Owner")] Business business)
    {

        @*Some code here...*@

        if (!(business == null))
        {
            business.Owner = System.Web.HttpContext.Current.User.Identity.Name;

            if (ModelState.IsValid)
            {
                db.Businesses.Add(business);
                db.SaveChanges();//This will save null data to database since these will get null values
                return RedirectToAction("Index", "Businesses");
            }

            return View(business);
        }

        return View("Success");
    }

How can I figure this out..?

shikiko
2#
shikiko Reply to 2017-12-05 01:57:58Z

You can just create a model and store the data there and later call it onto another view

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.349704 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO