ASP.Net Owin Authentication.SignOut在注销时未通过RedirectUri重定向用户



-下面进行了编辑-修改后的问题在底部:

我有一个多租户应用程序,它使用Azure AD对用户进行身份验证。

应用程序在注销时,似乎会忽略注销过程生命周期中的.RedirectUri属性。当最初注销时,我可以在这里看到应用程序最初正确重定向:

https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri={REDIRECT URI}(以及后面的QueryString变量(。

一旦此过程完成,应用程序将重定向到以下位置,并在不重定向回的情况下放置:https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession

这给用户提供了标准的";用户已经注销,关闭所有浏览器窗口是个好主意;。

如何防止最后一次重定向,并确保注销重定向回应用程序?

Dim callbackUrl As String = Request.Url.GetLeftPart(UriPartial.Authority) & Response.ApplyAppPathModifier("~/aservices/logout_response.aspx")
HttpContext.Current.GetOwinContext().Authentication.SignOut(
New AuthenticationProperties() With {.RedirectUri = callbackUrl},
OpenIdConnectAuthenticationDefaults.AuthenticationType,
CookieAuthenticationDefaults.AuthenticationType)

编辑:使用具有LogoutAction="Redirect"属性集的<asp:LoginStatus>控件似乎确实可以执行此操作。我如何在代码后台复制这种行为?

从评论中移动答案,

您需要在此登录状态控件中尝试Session.Abandon()。请参阅此处

最新更新