I have configured an error 500 page with a controller an a view to display when a 500 occures via the webconfig.
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<remove statusCode="500" />
<error statusCode="404" responseMode="ExecuteURL" path="/error/404" />
<error statusCode="500" responseMode="ExecuteURL" path="/error/500" />
</httpErrors>
In the application_error event i log the error
protected void Application_Error(object sender, EventArgs e)
{
var objErr = Server.GetLastError().GetBaseException();
var err = string.Concat("Error in: ", Request.Url, "\nMessage:", objErr.Message, "\nStack Trace:", objErr.StackTrace);
DatabaseLogging.WriteLog(err, 3);
}
On my dev envirement it works perfect, the exception is logged and the error page is shown. On the acceptance envirment the 500 error page is show, but the real error is not logged. The following error gets logged.
Message:The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/User/Error.aspx ~/Views/User/Error.ascx ~/Views/Shared/Error.aspx ~/Views/Shared/Error.ascx ~/Views/User/Error.cshtml ~/Views/User/Error.vbhtml ~/Views/Shared/Error.cshtml ~/Views/Shared/Error.vbhtml Stack Trace: at System.Web.Mvc.ViewResult.FindView(ControllerContext context) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0() at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d() at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Anyone got an idea how I can solve this problem? the following routes are mapped:
// Error pages
routes.MapRoute("Error404", "error/404", new { controller = "Error", action = "Error404" });
routes.MapRoute("Error500", "error/500", new { controller = "Error", action = "Error500" });