【发布时间】:2011-03-05 00:05:38
【问题描述】:
有什么方法可以在区域之间共享局部视图吗?
例如登录部分,如果我使用@Html.Partial("_LoginPartial"),但 Html.ActionLink 生成的 URL 是调用区域的本地部分(即使部分本身不是该区域的一部分)。
_LoginPartial.cshtml is in /Views/Shared/_LoginPartial.cshtml
Calling view is inside /Areas/Somearea/Views
Links generated are like: http://example.com/Somearea/Account/Login
But should always be: http://example.com/Account/Login
部分视图来源:
@if(Request.IsAuthenticated) {
<text>Welcome <b>@Context.User.Identity.Name</b>!
[ @Html.ActionLink(@Messages.Logout, "Logout", "Account") ]</text>
}
else {
@:[ @Html.ActionLink(@Messages.Login, "Login", "Account") ]
}
谢谢
【问题讨论】:
标签: asp.net asp.net-mvc razor asp.net-mvc-areas