I use the AbpMvcAuthorize attribute on many controller methods (not the entire controller) to grant privileges. However, if the user doesn't have that permission, the default action of the attribute seems to be to redirect back to the login page. Because I am using OpenID SSO, it redirects the user to the SSO login page. What I want to do is to just take them to a static "Unauthorized" page that I have created. Is that possible?
Thanks, Bryan
7 Answer(s)
-
0
Hi,
You can override HandleUnauthorizedRequest method of AbpMvcAuthorizeAttribute and redirect to unauthorized page.
-
0
Could you do this to redirect to different login pages based on area?
If so how?
Thanks in advance
Dale
-
0
Hi @DalePalmer,
I think it is possible. Have you tried it ? Did you get an error ?
-
0
Not too sure where to start on doing it to be honest.
Is it an override just for the controller? Just a bit of guidance would be really appreciated.
Thanks
Dale
-
0
Hi @DalePalmer,
Basically, you need to create a new attribute which is derived from AbpMvcAuthorizeAttribute. Then you need to override HandleUnauthorizedRequest method in it and use it in your controllers.
But there might be an easier solution as well. Are you sing MVC 5.x, Web API or ASP.NET Core ?
-
0
.net Core with JQuery
-
0
Hi,
Then you can define a custom middleware to handle this, please check this document for writing a custom middleware <a class="postlink" href="https://blogs.msdn.microsoft.com/dotnet/2016/09/19/custom-asp-net-core-middleware-example/">https://blogs.msdn.microsoft.com/dotnet ... e-example/</a>.