- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的项目基于 Visual Studio 2013 中的 MVC 5 项目模板(个人用户帐户选项)。我一直依赖用户的默认登录和注销方法。但我不确定我做了什么,在某些时候,用户无法再注销,但他们可以以其他用户的身份登录。
这是帐户 Controller 的默认注销方法
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut();
return RedirectToAction("Index", "Home");
}
private IAuthenticationManager AuthenticationManager
{
get
{
return HttpContext.GetOwinContext().Authentication;
}
}
这是显示用户用户名的默认 _LoginPartial.cshtml View 。
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a> </li>
</ul>
}
}
else
{
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
</ul>
}
当用户注销时,它会将用户定向到登录页面,但仍然显示用户的用户名,这意味着他们尚未注销。并且浏览器上的url显示 http://localhost/Account/Login?ReturnUrl=%2FAccount%2FLogOff
它不会将用户带回主页的索引页面。所以我的猜测是在 AuthenticationManager.SignOut(); 语句中发生了一些事情。我很困惑,因为我没有对帐户 Controller 进行任何更改。
任何线索将不胜感激。
最佳答案
我也遇到了同样的问题。在 CodePlex 上检查此问题:
http://web.archive.org/web/20160403071605/https://aspnetidentity.codeplex.com/workitem/2347
尝试将 AuthenticationManager.SignOut() 替换为AuthenticationManager.Signout(DefaultAuthenticationTypes.ApplicationCookie);
希望对你有帮助。 :-)
关于asp.net-mvc - MVC AuthenticationManager.SignOut() 未注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29090808/
我使用了单点登录演示:http://www.codeproject.com/KB/aspnet/SingleSignon.aspx 我为这个演示添加了SignOut功能,但发现了一个问题: 当我设置
什么是更详细的工作流程差异 GoogleSignInApi.signOut FirebaseAuth.signOut() GoogleSignInApi.revokeAccess. 浏览许多教程和代码
我有主页,其中有登录和注销栏。我有用户页面,其中还有一个注册表单。现在,如果我注销,它可以正常工作,但是一旦我刷新页面,它就可以正常工作,因为用户仍然没有注销。谁能帮我解决我的问题。 用户页面的 HT
firebase.initializeApp({ apiKey: 'AIza…', authDomain: '.firebasepp.com' }); // As httpOnly cooki
我正在使用目前处于 Beta 阶段的 Cognito 用户池来处理我网站上的用户帐户。 在 javascript 中我有一行: cognitoUser.signOut(); 应该将我的用户注销,我认为
在 ASP.NET MVC3 Controller 操作中,我想注销用户并返回 401 状态代码。代码很简单: public ActionResult Index() { FormsAuthenti
我正在开发一个带有安全部分的网站,即名为“PIP”的文件夹。 登录部分工作正常,但当我点击注销时,用户仍然是已知的,如果他/她接触安全部分,则不会被重定向到登录页面。 这是我的 web.config:
我正在使用 Sign-in with Google 方法在我的应用中登录用户。 问题 - 更新 : 如果我卸载应用程序(在退出后或未退出)并重新安装应用程序,FirebaseAuth.getInsta
我看到了一些与此主题相关的帖子,但给定的解决方案并没有真正为我澄清事情...... 所以,我正在开发一个 rails(版本 3.2.2)应用程序,它遵循 Michael Hartl 的 Ruby on
下面是我用来登录谷歌的代码。我在 login.php 上有一个 ID 为授权按钮的元素。当点击它登录就好了。 我的头文件中有一个注销链接。当我单击注销时,它会调用 gapi.auth.signOut(
把我的头砸得太久了。如何防止用户在使用 FormsAuthentication.SignOut 注销后浏览网站页面?我希望这样做: FormsAuthentication.SignOut(); Ses
我正在使用Firebase身份验证登出方法,但似乎无法正常工作。当我单击注销按钮时,应该注销当前用户。但是,执行此操作后,控制台不会指示firebase auth注销方法实际上正在工作,没有提示! 该
此问题似乎与 this 有关帖子,但我无法从线程中推断出解决方案。 我在继承的应用程序中注意到了这段代码(在日志文件中注意到异常被吃掉之后): protected void Session_E
在运行我的单元测试方法时,出现错误 FormsAuthentication.SignOut()。我已经像这样 mock 了 httpcontext var httpRequest = new Http
在我的 Web 应用程序中,我使用完全自定义的登录功能。因此,Web.Security 中没有任何内容。 我使用 Session 和 ViewState 变量控制一切。要从应用程序注销,我使用 Ses
我正在为一个应用程序进行注册 Activity ,但发生了一些奇怪的事情,你能帮帮我吗? 这是用于注册的代码,如果我评论 signOut 函数它会起作用,但我需要它在将数据保存在 FirebaseAu
我尝试从 firebase 中注销用户,但在我关闭我的应用程序并再次打开后,用户仍处于连接状态 我尝试从 firebase 中定期注销用户,但没有解决问题。我想知道是什么导致了这个问题 logout
有没有人帮我解决这个问题,在我的 asp.net 应用程序中,我正在使用 FormsAuthentication.SignOut();注销应用程序的方法,但我有一个奇怪的要求,我必须使用 Javasc
我在外部身份验证服务器中使用 OWIN 中间件,我的应用程序使用 OAuth 授权代码授予流程对其进行身份验证。 我可以重定向到身份验证服务器,针对外部提供商 (Google) 进行身份验证,然后使用
我正在尝试设置一个使用 OIDC 连接到我公司的 SSO 门户 (OpenAM) 的 ASP.net Core 3 MVC 应用程序。 我使用 Visual Studio 2019 项目生成器创建了一
我是一名优秀的程序员,十分优秀!