Alex Rivera | Logout

Razor actionlink autogenerating ?length=7 in URL?

Asked 2010-12-05T07:40:10.473
56

I have the link below on a razor page:

@Html.ActionLink("Create New Profile", "Create", "Profile", new { @class="toplink" })

It appears in thes source of view page as shown below:

<a href="/admin/profile/create?length=7" class="toplink">Create New Profile</a>

When I click on the link the URL is like this:

http://localhost:54876/admin/profile/create?length=7

I don't want ?length=7. Why is this auto generated?

Edit
Report

1 Answer

7

I'm not sure the exact cause of this, but change it to:

@Html.ActionLink("Create New Profile", "Create", "Profile", new {}, new { @class="toplink" })

I don't know which overload MVC is picking when you leave off the last parameter (htmlattributes is the added one), but that will fix it. One of these days I'll investigate and figure out exactly what's going on.

answered 2010-12-05T08:21:26.557

Your Answer