日期:2014-05-17 浏览次数:20471 次
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) {
switch (filterContext.HttpContext.Response.StatusCode) {
case 401:
filterContext.HttpContext.Response.Charset = "UTF-8";
//filterContext.HttpContext.Response.Write("<h4 style=\"font-family:微软雅黑;\">" + ErrorMessage + "</h4>");
filterContext.HttpContext.Response.Write("<script>setTimeout(\"document.location='/Home/Index'\",500);</script>");
filterContext.HttpContext.Response.End();
break;
case 403:
string newUrl = string.IsNullOrEmpty(this.AreaName) ? "/Home/Index" : "/" + this.Identity.Identity + "/Index";
filterContext.HttpContext.Response.Charset = "UTF-8";
filterContext.HttpContext.Response.Write("<script>setTimeout(\"document.location='" + newUrl + "'\",200);</script>");
filterContext.HttpContext.Response.End();
break;
default:
base.HandleUnauthorizedRequest(filterContext);
break;
}
}