2

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

<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看起来像是试图在成员区域中找到帐户控制器以调用注销的操作结果,但帐户控制器位于根目录中最初创建它的项目。

4

2 回答 2

0

That syntax looks correct. Is AccountController in a separate area than the default main area? You can also give this a try - https://t4mvc.codeplex.com/documentation. You can look at how Html.BeginForm is specified in that. The strong typing helps you avoid typos and mistakes.

于 2013-10-05T17:17:53.420 回答
0

我想通了,我使用了错误的构造函数。我需要将 null 作为参数放在最后才能使用正确的构造函数

于 2013-10-08T00:04:33.750 回答