asp.net mvc 4 - asp mvc friendly url routing problems -


i added next maproute routeconfig:

 routes.maproute(             name: "noticias",             url: "{controller}/{action}/{id}/{urlamiga}",             defaults: new                 {                     controller = "noticias",                     action = "noticia",                     id = "",                     urlamiga = ""                 }             ); 

and in view, have next:

 <a href="<%= url.action("noticia","noticias", new {id = item.idnoticia, urlamiga="this-is-a-test" }) %>">                                 <h5>                                     <%= item.titulo %>                                 </h5>                             </a> 

the controller:

 public actionresult noticia(int id)     {         var noticia = new noticiarepository().recuperarnoticiaporid(id);         viewbag.idnoticia = noticia.id;         return view("noticia", noticia);     } 

i generated links looks like:

http://www.domain/noticia/1123/this-is-a-test

but, result is:

http://www.domain/noticia?id=106532&urlamiga=this-is-a-test

why?

make sure have declared route before default one:

routes.maproute(     name: "noticias",     url: "{controller}/{action}/{id}/{urlamiga}",     defaults: new     {         controller = "noticias",         action = "noticia",         id = "",         urlamiga = ""     } );  routes.maproute(     name: "default",     url: "{controller}/{action}/{id}",     defaults: new     {         controller = "home",         action = "index",         id = urlparameter.optional,     } ); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -