So, I'm using the ASP.NET SimpleMembershipProvider user, roles and authorization structure. This controller requires the user is logged in, so that when it acesses this page while logged off, the login page appears.
[Authorize]
public class CompanyController : Controller
{
//stuff...
}
For this page, I want restricted access only to admins, so here it goes
[Authorize(Roles = "Admin")]
public class UserManagementController : Controller
{
//fields, methods, etc...
}
But when I try to access it logged off or logged in with a user account not in the "Admin" role, it shows the login page, but I wanted a custom page telling the user that page has restricted access and he does'nt have the credentials. How to do it, I mean without having to resort to if's and redirects in every method, that would blow the point of authorization atributes.
Thanx