Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Application_Error(object sender, EventArgs e)
- {
- var httpContext = ((HttpApplication)sender).Context;
- ExecuteErrorController(httpContext, Server.GetLastError());
- }
- public static void ExecuteErrorController(HttpContext httpContext, Exception exception)
- {
- if (!exception.Message.Contains("NotFound") && !exception.Message.Contains("ServerError"))
- {
- var routeData = new RouteData();
- routeData.Values["area"] = "Administration";
- routeData.Values["controller"] = "Error";
- routeData.Values["action"] = "Insert";
- routeData.Values["exception"] = exception;
- using (Controller controller = new ErrorController())
- {
- ((IController)controller).Execute(new RequestContext(new HttpContextWrapper(httpContext), routeData));
- }
- }
- }
- public ActionResult Insert(Exception exception)
- {
- ErrorSignal.FromCurrentContext().Raise(exception);
- Server.ClearError();
- Response.Clear();
- switch (Tools.GetHttpCode(exception)) // (int)HttpStatusCode.NotFound;
- {
- case 400:
- return RedirectToAction("BadRequest");
- case 401:
- return RedirectToAction("Unauthorized");
- case 403:
- return RedirectToAction("Forbidden");
- case 404:
- return RedirectToAction("NotFound");
- case 500:
- return RedirectToAction("ServerError");
- default:
- return RedirectToAction("DefaultError");
- }
- }
- public ActionResult Unauthorized()
- {
- return View();
- }
- ...
- //GlobalConfiguration.Configure(WebApiConfig.Register);
- //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
- Runtime Error
- Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.
- Details: To enable the details of this specific error message to be viewable on the local server machine, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".
- <!-- Web.Config Configuration File -->
- <configuration>
- <system.web>
- <customErrors mode="RemoteOnly"/>
- </system.web>
- </configuration>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement