How to redirect to a specific web page after sign out from Entra ID
With some more digging I found the below changes resulted in a successful redirect to a page of my choosing.
I found that if the SignedOutCallbackPath
is set to anything other than /signout-oidc
, then on sign out, the user gets redirected to /Account/SignOut
. This happens regardless of what SignedOutRedirectUri
gets set to, since it's hardcoded into the AccountController
provided as part of the Microsoft.Identity.Web.UI
nuget package.
This lead to the following OpenIdConnectOptions
configuration in Program.cs
builder.Services.Configure<OpenIdConnectOptions>(
OpenIdConnectDefaults.AuthenticationScheme,
options => {
options.SignedOutCallbackPath = "/signout-callback-oidc";
options.SignedOutRedirectUri = "/Account/SignOut";
});
Next, I implemented my own AccountController
, with a route that matches the signout redirect URI /Account/Signout
. In this controller action, I redirect to the page I want to display:
public class AccountController : Controller
{
public new IActionResult SignOut()
{
base.SignOut();
return RedirectToAction("Index", "Home");
}
}
Lastly, I updated my App Registration in Entra ID, setting "Front-channel logout URL" to match that of the SignedOutCallbackPath
property:
Users are now correctly redirected to the public home page of the site once they've successfully signed out.
A special thanks to Jalpa Panchal, whose response set me on the path of providing a custom implementation for URI that the site is being redirected to.
标签:redirect,web,Entra,sign,ID,page,out From: https://www.cnblogs.com/chucklu/p/18191881