Context.Response.SignOut 在 ASP.NET vNext beta 6 升级后不再存在
Context.Response.SignOut no longer exists after ASP.NET vNext beta 6 upgrade
在我的 ASP.NET vNext beta4 下的 AccountController 中,我们使用以下方式注销:
Context.Response.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
Context.Response.SignOut(CookieAuthenticationDefaults.AuthenticationType);
效果很好,用户最终进入了我们预期的 Office 365 登录页面。
更新到 beta6 后,SignOut 方法显示为错误。我们将其替换为以下内容,但注销似乎从未正确发生。用户会立即返回到已登录的主页。我已经尝试过 SignOutAsync 和 ForbidAsync,甚至两者都试过,但自更新以来仍然无法注销用户。
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);
在 beta6 中正确注销用户并将他们重定向到 Office 365 登录屏幕的推荐(或任何)方法是什么?
其余的控制器操作是什么?该行为最近发生了变化,在调用注销时立即应用重定向而不是延迟,请参阅:Similar issue
在我的 ASP.NET vNext beta4 下的 AccountController 中,我们使用以下方式注销:
Context.Response.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
Context.Response.SignOut(CookieAuthenticationDefaults.AuthenticationType);
效果很好,用户最终进入了我们预期的 Office 365 登录页面。
更新到 beta6 后,SignOut 方法显示为错误。我们将其替换为以下内容,但注销似乎从未正确发生。用户会立即返回到已登录的主页。我已经尝试过 SignOutAsync 和 ForbidAsync,甚至两者都试过,但自更新以来仍然无法注销用户。
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);
在 beta6 中正确注销用户并将他们重定向到 Office 365 登录屏幕的推荐(或任何)方法是什么?
其余的控制器操作是什么?该行为最近发生了变化,在调用注销时立即应用重定向而不是延迟,请参阅:Similar issue