0

I have an application with the custom form authentication. I have added restrictions on accessing to some actions based on user roles. I have overridden Application_PostAuthenticateRequest(Object sender, EventArgs e) and it works OK. The only problem is that currently the application redirects a user to a login page if for instance "Editor" is trying to access to actions available only for "Admins". I know it is because I have set the default page to log-in page in Web.config. Ideally I would like a user to be redirected to a warning page instead of a login page. How can I do it?

Thanks

EDIT: The answer to this question may also be found here: ASP.NET MVC redirect to an access denied page using a custom role provider

Community
  • 1
  • 1
Celdor
  • 2,437
  • 2
  • 23
  • 44
  • look into filters. http://msdn.microsoft.com/en-us/library/gg416513(VS.98).aspx – DLeh Jan 19 '15 at 14:12
  • similar question: http://stackoverflow.com/questions/977071/redirecting-unauthorized-controller-in-asp-net-mvc – user1666620 Jan 19 '15 at 14:12
  • also check http://stackoverflow.com/questions/1498727/asp-net-mvc-how-to-show-unauthorized-error-on-login-page – user1666620 Jan 19 '15 at 14:14
  • I found the perfect solution here: http://stackoverflow.com/questions/1279643/asp-net-mvc-redirect-to-an-access-denied-page-using-a-custom-role-provider Thanks guys! – Celdor Jan 19 '15 at 15:00

0 Answers0