Thank you for reaching out.
The issue happens because Response.Redirect() only writes a redirect header; it doesn’t stop the rest of the code from running in ASP.NET Core. The correct way is to return a redirect result, which satisfies the IActionResult requirement and properly ends the request.
Here’s the simple syntax you can use:
return`` Redirect("/Identity/Account/Login");
return`` RedirectToPage("Account/Login");
return`` LocalRedirect(returnUrl);
These methods are designed for controller actions and Razor Pages, so they work perfectly when your action returns IActionResult.
For more details, you can check the official Microsoft docs:
Please let us know if you require any further assistance, we’re happy to help.
If you found this information useful, kindly mark this as "Accept Answer".