0

I have a POST method that returns me to my summary page that looks like this

    public ActionResult SpecialOrderSelection(ItemViewModel model)
        {  
            if (ModelState.IsValid)
            {
                JobOrder jobOrder = db.JobOrders.Find(model.Id);
                if (jobOrder == null)
                {
                    return HttpNotFound();
                }
                ViewBag.JobOrderID = jobOrder.ID;
               
            }
            return SpecialOrderSummary(model);
            
        }

And here is my Summary GET method

  public ActionResult SpecialOrderSummary(ItemViewModel model)
        {
            return View("SpecialOrderSummary", model);
        }

It sends me to my SpecialOrderSummary View Page, however the URL still displays as what my POST method is and not my GET. Also on every refresh it goes to the post first.

Why is this?

  • I think you are looking for `RedirectToAction`. Maybe you should take a look at this answer: https://stackoverflow.com/questions/13020202/passing-a-model-object-to-a-redirecttoaction-without-polluting-the-url – Carlos Oliveira Jul 14 '20 at 22:17

1 Answers1

0

This is normal, because mvc runs like this.

You should use redirect,

  public ActionResult SpecialOrderSelection(ItemViewModel model)
    {  
        if (ModelState.IsValid)
        {
            JobOrder jobOrder = db.JobOrders.Find(model.Id);
            if (jobOrder == null)
            {
                return HttpNotFound();
            }
            ViewBag.JobOrderID = jobOrder.ID;
           
        }
        return Redirect("SpecialOrderSummary?(your model serialize)");;
        
    }