How to trigger openID authorization when Custom Attribute fail in ASP.net core MVC
Im porting a preveious application written in MVC 5 to ASP.net core MVC, So i created a custom attribute by following this link https://www.c-sharpcorner.com/blogs/authorization-attribute-in-asp-net-core-web-api and we have our own custom validation on it and if it is not allowed previously we just throw HandleUnauthorizedRequest() routine.
We use Keycloak in our authentication, that if we use the [Authorize] attribte in the ported code (ASP.net core mvc 6) it works and redirect to the keycloack login page. However following the tutorial from above, even if I try to throw UnauthorizedResult() or ForbidResult() in AuthorizationFilterContext.Result the page will just stop and will not go back to the Keycloak login page.
How to properly do this?