Reputation: 10618
I would like that the Index action doesn't appear in the url.
For example, I would like to see
www.mywebsite.com/MyController/1
instead of
www.mywebsite.com/MyController/Index/1
Is there something special I have to do in the Html.ActionLink tag or in the global.aspx file ?
Upvotes: 5
Views: 5034
Reputation:
yes you can by modifying your route like this:
routes.MapRoute(
"Default", // Route name
"{controller}/{id}", // URL with parameters
new { controller = "MyController", action = "Index", id = 1 } // Parameter defaults
);
Upvotes: 0
Reputation: 54894
Try this for your routes.
routes.MapRoute(
"Index",
"/{controller}/{id}",
new { controller = "Home", action = "Index" }
);
It sets the action to the default of "Index"
Upvotes: 3