ASP.NET MVC POST Parameter into RouteData
- by David Thomas Garcia
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?