I’m developing an ASP.NET Core application with Razor Pages, and I’ve implemented registration and login features. However, I’m facing a problem with the logout functionality. When a user clicks on the logout button, the user is supposed to be redirected to a specific page, but instead, I’m encountering a white screen issue.
The current behavior is as follows: after clicking the logout button, the browser is redirected to "https://localhost:7082/signout-oidc?state=longstring", where I am greeted with a white screen. My expectation is to redirect the user to the home page or a specified page after logging out.
Here is the relevant code:
Logout button in Razor Page:
<a href='@Url.Action("SignOut", "Account", new { Area = "MicrosoftIdentity" })' class="logout-button">Logout</a>
SignOut action in the Account controller:
public async Task<IActionResult> SignOut()
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToPage("/Index");
}
I suspect the issue might be related to the way the sign-out process is being handled or maybe the redirection after the sign-out is not correctly configured. The redirect for sign-out is set to "https://localhost:7082/signout-oidc", but it doesn’t seem to work as intended.
Has anyone encountered a similar issue or can provide insights into what I might be doing wrong? How can I ensure that after the sign-out process, the user is redirected to a designated page (like the home page) instead of being left on a white screen?
Any help or suggestions would be greatly appreciated!
2
Answers
I was using this service configure in my Program.cs. I deleted this codeblock and it works fine now.
You could specify signout property in singoutasync method.
You could also set a global redirect url in program.cs