gpt4 book ai didi

c# - 注销并重定向到不同区域的主页

转载 作者:行者123 更新时间:2023-11-28 03:28:58 25 4
gpt4 key购买 nike

我试图注销一个页面并让它重定向回主页,但它似乎不能自己离开该区域。

<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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com