Im using role based authorization and it works fine, but for one controller I want a different redirect url than the default one for one controller. My current code:
[Authorize(Roles = nameof(EIdentityType.Support))]
[Route("[controller]")]
public class AdminController : Controller
{
//CLASS METHODS
}
This redirects the user to
/Account/Login?ReturnUrl=%2Fadmin
However I want the user (for this specific controller so not for other controllers) to be redirected to
/admin/login
I found examples for asp.net mvc-4 which explains how to do it but the example wont work for .net core because in .net core the method HandleUnauthorizedRequest
cant be overriden (it does not exist in .net core AuthorizeAttribute
).
How can I set a custom redirect URL for a specific controller in .net core when using role based authorization?