I am using Windows Authentication in my MVC application with the WindowsTokenRoleProvider. I created a controller action that looks like:
[Authorize(Roles=@"Fake\Role")]
public ActionResult Admin()
{
return View();
}
When I try and hit this page I see a blank page. Is there a way for me to display a custom view that says "You are not authorized to view this page" isntead of just showing a blank page. If I was using forms authentication then it would redirect me to the login page, but that doesn't really make sense 开发者_JS百科for Windows Authentication since you never really log in specifically.
You most likely are not getting a blank page (I'm not absolutely certain). You are most likely getting a http response that has no content, but has a 403 not authorized status code.
Assuming this is accurate, all you need to do is setup in ASP.NET custom errors (and IIS custom errors) is a redirect rule for 403 codes to the appropriate page.
精彩评论