繁体   English   中英

注销并重定向到其他区域的主页

[英]log off and be redirect to home page in different area

我试图注销一个页面并将其重定向回首页,但它本身似乎无法离开该区域。

<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。
当您登录时,它会将您发送到成员区域,然后当您单击注销时,URL更改为/member/account/logoff ,这似乎是它试图在成员区域中找到帐户控制器以调用注销的动作结果,但是该帐户控制器位于最初创建该项目的项目的根目录中。

该语法看起来正确。 AccountController是否位于与默认主区域不同的区域中? 您也可以尝试一下-https: //t4mvc.codeplex.com/documentation 您可以查看其中如何指定Html.BeginForm。 强类型可以帮助您避免输入错误和错误。

我发现,我使用了错误的构造函数。 我需要在最后放置null作为参数以使用正确的构造函数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM