0

Why is this

<%=Html.ActionLink("Users", "Index", "Users", new { id = "3" })%>

Pointing to this

http://localhost:1798/Users/Index?Length=8

Instead of this

http://localhost:1798/Users/Index/3

Registered Routes Method:

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Users", action = "Index", id = "" }  // Parameter defaults
        );

    }
1
  • What does your RegisterRoutes method in your global.asax look like? Commented Sep 8, 2009 at 20:48

1 Answer 1

2

It should be:

<%= Html.ActionLink("Users", "Index", new {Id=3})
Sign up to request clarification or add additional context in comments.

1 Comment

This only works it's used in a UsersController view. Otherwise it won't know what controller to call. To force it to a controller, use Html.ActionLink("Users", "Index", "Users", new { id = 3 }, null)

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.