asp.net mvc - After a change to the default routing map my actionlinks stopped working -
i made change routing map following now:
routes.maproute( name: "default", url: "{controller}/{action}/{id}/{title}", defaults: new { controller = "home", action = "index", id = urlparameter.optional, title = urlparameter.optional } );
and actionlinks not working anymore:
@html.actionlink("category", "categorylist", "category")
when click on actionlink nothing happens url stays same http://localhost:62394/
page reloads. weird
and when check html looks this:
<a href="">category</a>
any kind of or tips appreciate alot!
note: if remove title routing works...
it's because you've got 2 optional parameters routing engine doesn't know 1 map third parameter to. feels title going used specific route rather generic one. if that's case, why not create specific route , remove generic fallback route?
something this:
routes.maproute( name: "title", url: "category-list/{title}", defaults: new { controller = "category", action = "categorylist", title = urlparameter.optional } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } );
Comments
Post a Comment