Razor actionlink autogenerating ?length=7 in URL?

前端 未结 3 1685
无人及你
无人及你 2020-11-28 08:39

I have the link below on a razor page:

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

It app

3条回答
  •  情话喂你
    2020-11-28 08:57

    Another thing to note, since you are defining the controller in the @ActionLink, which you may not need to do, for example, the view that your "Create New Profile" @ActionLink is expressed in might be "/admin/profile/index.cshtml", a view that lists existing profiles, in this case, you do not need to define the controller in the @ActionLink as the @ActionLink is already relative to the ProfileController, so your @ActionLink could be

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

    I used null instead of new{} as the marked answer does, I think this is more appropriate myself. ActionLink overloads are not the most straightforward thing ever.

提交回复
热议问题