private void ApplicationError(object sender, EventArgs e) { Exception exception = ((HttpApplication)sender).Server.GetLastError().InnerException; HttpContext context = ((HttpApplication)sender).Context; string redirectUrl = "~/error.aspx"; if (String.IsNullOrEmpty(redirectUrl)) { return; } WebAdminPage.SetCurrentException(context, exception); ((HttpApplication)sender).Server.Transfer(String.Format(CultureInfo.InvariantCulture, redirectUrl), true); }
private void OnEnter(Object sender, EventArgs eventArgs) { HttpApplication application = (HttpApplication)sender; if (!application.Context.Request.IsLocal) { SecurityException securityException = new SecurityException((string)HttpContext.GetGlobalResourceObject("GlobalResources", "WebAdmin_ConfigurationIsLocalOnly")); WebAdminPage.SetCurrentException(application.Context, securityException); application.Server.Transfer("~/error.aspx"); } if (application != null) { SetSessionVariables(application); } application.Response.Cache.SetCacheability(HttpCacheability.NoCache); }
private void SetSessionVariables(HttpApplication application) { string queryStringAppPath = string.Empty; string queryStringApplicationPhysicalPath = string.Empty; string applicationPath = string.Empty; string applicationPhysicalPath = string.Empty; string setAppPath = string.Empty; string setAppPhysPath = string.Empty; try { SecurityPermission permission = new SecurityPermission(PermissionState.Unrestricted); permission.Demand(); } catch { Exception permissionException = new Exception((string)HttpContext.GetGlobalResourceObject("GlobalResources", "FullTrustRequired")); WebAdminPage.SetCurrentException(application.Context, permissionException); application.Server.Transfer("~/error.aspx"); } if (application.Context.Request != null) { queryStringAppPath = (string)application.Context.Request.QueryString["applicationUrl"]; queryStringApplicationPhysicalPath = (string)application.Context.Request.QueryString["applicationPhysicalPath"]; } if (application.Context.Session != null) { if (application.Context.Session[APP_PATH] != null) { applicationPath = (string)application.Context.Session[APP_PATH]; } if (application.Context.Session[APP_PHYSICAL_PATH] != null) { applicationPhysicalPath = (string)application.Context.Session[APP_PHYSICAL_PATH]; } } if ((String.IsNullOrEmpty(queryStringAppPath) && applicationPath == null) || (String.IsNullOrEmpty(queryStringApplicationPhysicalPath) && applicationPhysicalPath == null)) { application.Server.Transfer("~/home0.aspx", false); return; } if (!String.IsNullOrEmpty(queryStringAppPath)) { setAppPath = queryStringAppPath; } else if (!String.IsNullOrEmpty(applicationPath)) { setAppPath = applicationPath; } if (!String.IsNullOrEmpty(queryStringApplicationPhysicalPath)) { setAppPhysPath = queryStringApplicationPhysicalPath; } else if (!String.IsNullOrEmpty(applicationPhysicalPath)) { setAppPhysPath = applicationPhysicalPath; } if (application.Context.Session != null) { application.Context.Session[APP_PATH] = setAppPath; application.Context.Session[APP_PHYSICAL_PATH] = setAppPhysPath; application.Context.Session[REMOTING_MANAGER] = new WebAdminRemotingManager(setAppPath, setAppPhysPath, application.Context.Session); } }