asp.net mvc - MVC3 Url Routing issue -
i trying register route follows :
routes.maproute( "salereport", // route name "salereport/getdataconsolidated/{type}", new { controller = "salereport", action = "getdataconsolidated", type = urlparameter.optional});
and in controller
public actionresult getdataconsolidated(string type) { homecoming content("report type = " + type); }
i calling : localhost:56674/salereport/getdataconsolidated/sale
but problem value of type null. doing wrong ?
it's order of .maproute(...)
calls.
put "salereport" .maproute(...)
phone call before "default" {controller}/{action}
.maproute(...)
call, since it's more specific.
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "salereport", url: "salereport/getdataconsolidated/{type}", defaults: new { controller = "salereport", action = "getdataconsolidated", type = urlparameter.optional }); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); }
asp.net-mvc asp.net-mvc-3 asp.net-mvc-routing
No comments:
Post a Comment