Html.ActionLink()中的问题是,您无法在其生成的标记内添加其他HTML内容。 例如,如果你想添加一个图标,除了像文字:如何在Url.Action中传递区域?
<a href="/Admin/Users"><i class="fa fa-users"></i> Go to Users</a>
使用Html.ActionLink(),只能生成:
<a href="/Admin/Users">Go to Users</a>
因此,要解决这个问题,你可以使用Url.Action()只产生像标签里面的网址:
// Here, Url.Action could not generate the URL "/admin/users". So this doesn't work.
<a href="@Url.Action("", "Users", "Admin")"><i class="fa fa-usesr"></i> Go to Users</a>
// This works, as we know it but won't pass the Area needed.
<a href="@Url.Action("", "Users")"><i class="fa fa-users"></i> Go to Users</a>
那么,你如何通过使用Url.Action面积()?
非常感谢您提前!
'Url.Action(“actionName”,“controllerName”,new {Area =“areaName”});' – haim770
对于根区'new {Area =“”}' – Corio