Matthew Jones
Matthew Jones

Reputation: 26190

ASP.NET Membership Redirect User on Denial of Access

I want to redirect the user to a custom error page when s/he is denied access to a page because of ASP.NET Membership's Roles. I thought this could be solved by the customErrors section of the web.config file, but none of the errors I've tried has caught it.

In other words, if a user is in the role "Project Focal" access, and tries to access a page that is authorized only for users in the role "Administrator", I want ASP.NET to redirect this user to a special page where I can record the error and help the user.

This sounds like a simple requirement, but none of my googling has found an answer. Any help would be greatly appreciated.

Upvotes: 0

Views: 661

Answers (1)

Ta01
Ta01

Reputation: 31610

Your answer lies here

It has a good explanation as well as why you have to use Application_EndRequest in this case.

Upvotes: 2

Related Questions