Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC RedirectToAction Passing Wrong Parameter Value?
    primarykey
    data
    text
    <p>I am using ASP.NET MVC 1.0. I have an ActionResult which receives a form post with a value from a drop down list. It then redirects to an ActionResult, passing the value as a parameter. Here are my 2 ActionResult methods:</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult FindPromo() { var promoId = Convert.ToInt32(Request.Form["ddlPromotion"]); return RedirectToAction("GetPromo", new { id= promoId }); } public ActionResult GetPromo(int id) { if (promoId &gt; 0) { var model = GetModel(id); if (model.Promo != null) { return View("Promo", GetModel(id)); } } return RedirectToAction("NotFound"); } </code></pre> <p>When I debug this, the value from the drop down list is pulled correctly from my form, but on the redirect, a different value from a previous request comes through as the promoId value on the GetPromo method. This happens even if I I totally close out of the page and reload it, almost as if it's cached somewhere. I know this is something simple, but I've never run across this before.</p> <p>EDIT:</p> <p>I changed the parameter names from promoId to id, and also updated my routing table. I've updated my code sample above, and here are my routes:</p> <pre><code> routes.MapRoute("GetPromo", "{controller}/GetPromo/{id}", new { controller = "Promo", action = "GetPromo" }); routes.MapRoute("FindPromo", "{controller}/FindPromo/{id}", new { controller = "Promo", action = "FindPromo" }); </code></pre> <p>I'm still getting the same results with the parameters, however.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload