日期:2014-05-17 浏览次数:20442 次
private void Application_BeginRequest(Object source, EventArgs e) { // Create HttpApplication and HttpContext objects to access // request and response properties. HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; // string s = context.Request.Url.ToString(); string filePath = context.Request.FilePath; string fileExtension = VirtualPathUtility.GetExtension(filePath); string path = Regex.Match(filePath, @"[Index]+").ToString(); if (path == "Index") { if (Common.IsLogin() == false) //判断用户是否登陆 ///大侠们看这边!!!!! { context.Response.End(); context.Response.Redirect("/"); } } //if (fileExtension.Equals("/Index/Index")) //{ // // string s = context.Request.Url.AbsolutePath.ToString(); // context.Response.Write("<h1><font color=red>" + // "VerificationModule: Beginning of Request" + // "</font></h1><hr>"); //} }
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 (CC6UU_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("/"); } }