nacho10f
nacho10f

Reputation: 5886

Help with asp.net routing

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

    }

Upvotes: 0

Views: 64

Answers (1)

Jason N. Gaylord
Jason N. Gaylord

Reputation: 8324

It should be:

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

Upvotes: 2

Related Questions