Context.Response.SignOut no longer exists after ASP.NET vNext beta 6 upgrade

余生颓废 提交于 2019-12-11 04:18:43

问题


In my AccountController under beta4 of ASP.NET vNext, we were logging out by using:

Context.Response.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
Context.Response.SignOut(CookieAuthenticationDefaults.AuthenticationType);

This worked great and the user ended up on the login page of Office 365 as we expected.

After updating to beta6, the SignOut method was shown as an error. We replaced it with the below, but the logout never seems to correctly happen. The user is immediately thrown back to the Home Page logged in. I have tried SignOutAsync and ForbidAsync and even both of them together, but still can't log user out since update.

var properties = new AuthenticationProperties
    {
        AllowRefresh = false,
        ExpiresUtc = DateTime.UtcNow.AddDays(-1),
        IsPersistent = true,
        RedirectUri = "/",
        IssuedUtc = DateTime.UtcNow
    };
await     Context.Authentication.SignOutAsync(OpenIdConnectAuthenticationDefaults.AuthenticationScheme, properties);
await Context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationType, properties);

What is the recommended (or any) way to correctly log out a user in beta6 and have them re-directed to the Office 365 login screen?


回答1:


What's in the rest of your controller action? The behavior has changed recently where redirects are applied immediately when sign out is called rather than delayed, see: Similar issue



来源:https://stackoverflow.com/questions/31679790/context-response-signout-no-longer-exists-after-asp-net-vnext-beta-6-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!