asp.net mvc - passing query string after the controller name in mvc -
i trying pass parameter in mvc after controller name
i added
routes.maproute( name: "product", url: "product/{*id}", defaults: new { controller = "product", action = "index", id = urlparameter.optional } );
this did not work
i tried url: "product/{id}",
but if remove lines above it(the lines below in post), working
routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } );
order in register routes matter. first route matches request used. if understand correctly, had:
routes.maproute( name: "default", ... routes.maproute( name: "product",
default route generic, , since registered first picked time of requests, shadowing product route.
correct way registed routes start specific ones, , have generic registered @ end. in case should reversed:
routes.maproute( name: "product", ... routes.maproute( name: "default",
Comments
Post a Comment