asp.net mvc - I'm not getting friendly url in a form with GET method -


i setup route that:

routes.maproute(     name: "pesquisar",     url: "pesquisar/{aaa}/{bbb}/{id}",     defaults: new { controller = "home", action = "pesquisar",                     aaa = urlparameter.optional,                     bbb = urlparameter.optional,                     id = urlparameter.optional     } ); 

when press send button in form (with method) url that:

http://localhost:00000/pesquisar?aaa=one&bbb=two 

but expecting for:

http://localhost:00000/pesquisar/one/two 

when map rout, adds end of list. when router looks rule match, starts @ begining of list , itterates through it. take first rule matches, not specific rule. because natural append code end, default rule (which works everything) @ start.

try re-ordering code this:

        ///the specific rout want use         routes.maproute(         name: "pesquisar",         url: "{action}/{aaa}/{bbb}/{id}",         defaults: new { controller = "home", action = "pesquisar",                         aaa = urlparameter.optional,                         bbb = urlparameter.optional,                         id = urlparameter.optional         }         );          ///the generic catch router         routes.maproute(             name: "default",             url: "{controller}/{action}/{id}",             defaults: new { controller = "home", action = "index", id = urlparameter.optional }         ); 

more information can found in question:
setting asp.net mvc 4 routing custom segment variables


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -