I'm using Azure AD for the login in my ASP.NET Core app. The sign out link is <a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">
, and after the sign out is successful it redirects me to MicrosoftIdentity/Account/SignedOut
. How can I have it redirect to another page?
Asked
Active
Viewed 4,342 times
0

System Down
- 6,192
- 1
- 30
- 34
-
1It's under the Customised Branding: https://stackoverflow.com/a/46763191/495455 – Jeremy Thompson Nov 07 '20 at 04:01
2 Answers
5
In this case, you could build your own AccountController
instead of the default one in the official sample, or use a URL Rewriting Middleware
to redirect the URL you want.
Reference - How to specify custom logout URL when using Azure AD authentication in .NET core

Joy Wang
- 39,905
- 3
- 30
- 54
-
2The AccountController was moved from ASP.NET Core to Microsoft.Identity.Web. Is this still the solution? The AccountController seems pretty useless if you can't even redirect back to your own webpages. – Jason Honingford Dec 03 '20 at 01:42
0
You can use this in your middleware (startup/program file) to redirect back to homepage on signout:
builder.Services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProviderForSignOut = context =>
{
context.ProtocolMessage.PostLogoutRedirectUri = context.Request.Scheme + "://" + context.Request.Host + "/";
return Task.FromResult(0);
}
};
});

Craig
- 849
- 8
- 21