日期:2014-05-18 浏览次数:20555 次
public class AuthorizeLogin : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { string url = httpContext.Request.RawUrl; if (url.Equals("/") || url.Contains("/Home/LoginOn/") || url.Contains("/Home/CheckCode")) { return true; } if (Admin.Commom.AdminInfo.Session == null) { httpContext.Response.StatusCode = 404; return false; } else { return true; } } public override void OnAuthorization(AuthorizationContext filterContext) { base.OnAuthorization(filterContext); if (filterContext.HttpContext.Response.StatusCode == 404) { filterContext.Result = new RedirectResult("/"); } }