我有一个 MVC 应用程序,其中配置了区域。注销链接出现在布局页面中,因此它显示在每个页面上。当我单击注销时,它总是将其附加到它所在的区域...
我只想让它转到帐户\注销 - 没有区域
我尝试了以下但没有用...有什么建议吗?
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", area="" }))
{
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
最佳答案
您正在使用不同的重载。我认为您应该按以下方式进行操作:
@using (Html.BeginForm("LogOff", "Account", new { area = ""}, FormMethod.Post, new { id = "logoutForm" }))
{
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
关于asp.net-mvc-4 - 如何在 MVC 4 中不为表单指定区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19331423/