protected void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs // Get the exception object. Exception exc = Server.GetLastError(); // Handle HTTP errors if (exc != null && exc.GetType() == typeof(HttpException)) { if (SiteConfigurationReader.EnableHttpErrorLog) { ExceptionManager.Manage(exc); } // The Complete Error Handling Example generates // some errors using URLs with "NoCatch" in them; // ignore these here to simulate what would happen // if a global.asax handler were not implemented. if (exc.Message.Contains("NoCatch") || exc.Message.Contains("maxUrlLength")) { return; } //Redirect HTTP errors to HttpError page //WebHelper.CurrentSession.Content.ErrorMessage = ExceptionManager.BuildErrorStack(exc); //UrlHelper url = new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext); //Response.Redirect(url.Action(Constants.Actions.Error, Constants.Controllers.Home, new { Area="" })); } else { // Log the exception and notify system operators if (exc != null) { if (exc.GetType() == typeof(CustomException)) { WebHelper.CurrentSession.Content.ErrorMessage = exc.Message; } else { WebHelper.CurrentSession.Content.ErrorMessage = ExceptionManager.BuildErrorStack(exc); } ExceptionManager.Manage(exc); } try { if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Url != null && !HttpContext.Current.Request.Url.ToString().Contains("Error")) { UrlHelper url = new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext); Response.Redirect(url.Action(Constants.Actions.Error, Constants.Controllers.Home, new { Area = "" })); } } catch { } } // Clear the error from the server Server.ClearError(); }