I successfully implemented role based authorization in ASP.NET. When a person does not have the needed role he gets to see an error page for 401.2 not authorized.
W
Here's what worked well for me.
Global.asax -
protected void Application_EndRequest(object sender, EventArgs e)
{
if (Response.StatusCode == 401 && Request.IsAuthenticated)
{
Response.StatusCode = 303;
Response.Clear();
Response.Redirect("~/AccessDenied.html");
Response.End();
}
}
Web.config -
This takes care of the double 401 before a 200 issue as well. Also circumvents the pesky firefox authentication popup.