Charlie Brown
Charlie Brown

Reputation: 2825

ASP.Net MVC Routing URL Generation

Html.ActionLink appends "Index", the action name to the end of the urls, but i would like to not have the index action listed in the default controller url (hope that makes some sense...)

Not Wanted: /ControllerName/Index WANTED: /ControllerName

Below is my routing setup:

            routes.MapRoute(
                null,
                "{controller}/{action}/{id}",
                null,
                new { id = @"\d+" }
            );

            routes.MapRoute(
                null,
                "{controller}/{action}"
            );

            routes.MapRoute(
                null,
                "{controller}",
                new { action = "Index" }
            );

            routes.MapRoute(
                null,
                "",
                new { controller = "Home", action = "Index" }
            );

Upvotes: 2

Views: 334

Answers (1)

David Morton
David Morton

Reputation: 16505

Flip them all around. The routes, as you've listed them, should be in the reverse order you've listed them in.

Upvotes: 3

Related Questions