KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm having an issue with custom errors on an ASP.NET MVC app I've deployed on my shared host. I've created an ErrorController and added the following code to Global.asax to catch unhandled exceptions, log them, and then transfer control to the ErrorController to display custom errors. This code is taken from here : protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); Response.Clear(); HttpException httpEx = ex as HttpException; RouteData routeData = new RouteData(); routeData.Values.Add("controller", "Error"); if (httpEx == null) { routeData.Values.Add("action", "Index"); } else { switch (httpEx.GetHttpCode()) { case 404: routeData.Values.Add("action", "HttpError404"); break; case 500: routeData.Values.Add("action", "HttpError500"); break; case 503: routeData.Values.Add("action", "HttpError503"); break; default: routeData.Values.Add("action", "Index"); break; } } ExceptionLogger.LogException(ex); // <- This is working. Errors get logged routeData.Values.Add("error", ex); Server.ClearError(); IController controller = new ErrorController(); // The next line doesn't seem to be working controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData)); } Application_Error is definitely firing because the logging works fine, but instead of displaying my custom error pages, I get the Go Daddy generic ones. From the title of the blog post the above code is taken from, I notice that it uses Release Candidate 2 of the MVC framework. Did something change
Tags (comma-separated)
Save Edits
Cancel