Parameter not being passed to Controller's action in ASP.NET MVC
I have two actions in a controller and yet the parameters are not being passed into one of them.
This one: /RouteStop/List/1
And this one: /RouteStop/Details/100
And my global.asax:
routes.MapRoute(
"List",
"{controller}/{action}/{id}",
new { controller = "RouteStop", action = "List", id = UrlParameter.Optional }
);
routes.MapRoute( "Details", "{controller}/{action}/{routeID}", new { controller = "RouteStop", action = "Details", routeID = UrlParameter.Optional } );
And here's the act开发者_StackOverflowions from my Controller:
public ActionResult List(string id)
{
return View();
}
public ActionResult Details(string routeID) { return View(); }
When I access this URL (/RouteStop/Details/100) the parameter gets passed just fine. But when I access the other one (/RouteStop/List/1) the parameter is null. The names match up as they should but I can't figure it out.
Try replacing {controller}
with List and Details in respective routes. but for your scenario the default routing that you get when you create an MVC app should work.
精彩评论