tags:

views:

31

answers:

1

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
        );

    }
+2  A: 

It should be:

<%= Html.ActionLink("Users", "Index", new {Id=3})
Jason N. Gaylord
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)`
Manticore