我试图注销一个页面并让它重定向回主页,但它似乎不能自己离开该区域。
<div class="container">
<div class="pull-right">
<div class="span12">
@using (Html.BeginForm("LogOff", "Account", new { area = ""}, FormMethod.Post, new { id = "logoutForm" }))
{
@Html.AntiForgeryToken()
<text>
Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", htmlAttributes: new { @class = "username", title = "Manage" })! | <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
</text>
}
</div>
</div>
</div>
以上是_LoginPartial.cshtml。
当您登录时,它会将您带到成员(member)区,然后当您点击注销时,网址会更改为
/member/account/logoff
看起来它试图在成员区域中找到帐户 Controller 以调用注销的 actionresult 但帐户 Controller 位于最初创建它的项目的根目录中。
最佳答案
该语法看起来是正确的。 AccountController 是否位于与默认主区域不同的区域?您也可以尝试一下 - https://t4mvc.codeplex.com/documentation .您可以查看其中如何指定 Html.BeginForm。强类型可帮助您避免错别字和错误。
关于c# - 注销并重定向到不同区域的主页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19199511/