Jim*_*son 5 c# asp.net identityserver4
我在连接到 Identity Server 4 服务器以进行登录和注销的 Asp.net MVC .net 4.5 Web 项目中。登录就好了。当我尝试注销 Request.IsAuthenticated 仍然是真的。我可以刷新,并且在关闭浏览器之前我仍然处于登录状态。当我打开它时,它会进入 Identity Server 登录页面。任何想法为什么?
退出代码:
Request.GetOwinContext().Authentication.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationType);
Session.Clear();
Session.Abandon();
Run Code Online (Sandbox Code Playgroud)
响应头:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
过期:-1
服务器:Kestrel
Set-Cookie:idsrv.session=.; 到期=格林威治标准时间 2017 年 9 月 17 日星期日 20:50:52;路径=/;Secure
Set-Cookie: idsrv=; 到期=格林威治标准时间 1970 年 1 月 1 日星期四 00:00:00;路径=/;Secure
X-Powered-By:ASP.NET
日期:2018 年 9 月 17 日星期一 20:50:52 GMT
Strict-Transport-Security:max-age=157680000
内容长度:601
请求头:
GET /XWAdmin/account/login HTTP/1.1 Host: localhost Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 接受: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng, /;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9 Cookie: rurl=/XWAdmin/; __RequestVerificationToken_L1hXQWRtaW41=wElsOf5d9ti5DtEOmBmEuD9WqhyFAIeVxbIGEFJ9axRvlBQkl2szOHZF5K8wnLG6o8djmjOoI1lk4FavA8X2mHzg3L7x8Q1 .aspNet。iob6tKq09CtobrleLwjcWs97kSw0chDZhWoc8DBrE61NiUfiGrFJTl3GsZoWLEGQkeNxKwG-fmB4Z6zdjiu_lgtMIrLGzemSBh92P7nnd7BCuA1axU-70GZEgk; .
这就是我为让它结合多个建议而工作的方法:
string[] ss = Request.GetOwinContext().Authentication.GetAuthenticationTypes().Select(o => o.AuthenticationType).ToArray();
Request.GetOwinContext().Authentication.SignOut(
new AuthenticationProperties
{
RedirectUri = Online.Server.Busi.Auth.Authentication.GetSingleSignOnRedirectUrl()
},
ss);
try
{
Session.Clear();
Session.Abandon();
}
catch
{ }
// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
Run Code Online (Sandbox Code Playgroud)