Frage

I've been playing around with ELMAH in my MVC4 application. I've downloaded ELMAH from Nuget and it sets the configuration for me. I know that ELMAH for MVC will catch errors in controllers, but how about errors else where? For instance error inside Application_Start? I've managed to log errors with ELMAH in the Application_Error but unable to redirect it to MVC 4 error page in the /Shared/ folder. Is even this possible?

War es hilfreich?

Lösung

yes - for a local environment, the redirect won't work unless you have the web.config set to customErrors mode="On" defaultRedirect="Error" and then you need to disable the global filter HandleError. Comment out the HandleErrorAttribute line in RegisterGlobalFilters.

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    //filters.Add(new HandleErrorAttribute());
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top