I came across a scenario, to pass more parameters in the controller. Product-> sub product -> sub-sub- product. and most of the suggestion in the website request us to create a querystring with /id?param1=""¶m2=""
But, I found the following is working for me (MVC 2)
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}/{param1}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional, param1 = UrlParameter.Optional } // Parameter defaults
);
}
mmm... also found the sme in http://forums.asp.net/t/1500133.aspx
This should be possible in MVC 1.The OptionalParameter is a new feature in MVC 2 inclusion, but in MVC1 I think same should be possible by passing empty string.
No comments:
Post a Comment