ASP.NET MVC POST Parameter into RouteData
Posted
by David Thomas Garcia
on Stack Overflow
See other posts from Stack Overflow
or by David Thomas Garcia
Published on 2010-03-31T05:31:04Z
Indexed on
2010/03/31
5:33 UTC
Read the original article
Hit count: 576
I'm using jQuery to POST an Id to my route, for example:
http://localhost:1234/Load/Delete
with a POST Parameter Id = 1
I'm only using the default route in Global.asax.cs right now:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
When I perform the POST, in my ActionFilter filterContext.RouteData.Values["Id"]
is set to the default value of ""
. Ideally, I'd like it to use the POST Parameter value automatically if the URL comes up with ""
. I know it is posting properly because I can see the value of "1"
in filterContext.HttpContext.Request.Params["Id"]
.
Is there a way to get RouteData to use a POST parameter as a fall back value?
© Stack Overflow or respective owner