Search code examples
asp.netvb.netlogin-controlrole-base-authorization

ASP.net How to handle login/logout with role based access


Scenario: I have the membership provider setup and its currently pointing to a SQL database on my machine. The role based access works and I have a menu that is security trimmed. The user can only get to pages that they have access to.

Problem: When an anonymous user tries to get to a page that they dont have access to it brings them to a login page so that they can login. That is fine. But when a logged in user tries to get to a page they dont have access to(Usually by typing in a URL) it brings them to the login page again asking them to login(except there already logged in. I'd like to either take them to a different page or somehow tell them they don't have access. Any ideas/suggestions?

Thanks in advance


Solution

  • This is what I use. They point out that using <customErrors> won't work because of the way the 401 status gets changed and provide a solution.