2

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" }
            );
1
  • my Html.ActionLinks that go to index, don't append index onto the link... even though i supply "Index" as the target action it just links to /ControllerName Commented Feb 23, 2010 at 21:53

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, why am I not surprised that its something so simple?
Yes, you're right, thats possible (just deleted my answer). Defining an action as a default one can be usefull in that example. +1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.