i need url http://localhost:53249/admin/editposts/1/edit
unfortunately m getting query string in url http://localhost:53249/admin/editposts?id=1&operation=edit
this actionlink(anchor tag)
<td>@html.actionlink(@posts.title, "editposts", "admin", new { id = posts.id, operation="detail" }, null)</td>
this route config:
public static void registerroutes(routecollection routes) { //routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.mapmvcattributeroutes(); routes.maproute( name: "admin", url: "admin/editposts/{id}/{operation}", defaults: new { controller = "admin", action = "editposts"} ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); }
in case mixing action , operation.
i suggest use url this:
http://localhost:53249/admin/posts/1/edit
because way indicate action, edit, posts objects, , edit action, not operation, following standard rest.
to use url suggested must change maproute to:
routes.maproute( name: "admin", url: "admin/posts/{id}/{action}", defaults: new { controller = "posts", action = "details" } //details action default );
Comments
Post a Comment