I am logging errors in my controllers method:
protected override void OnException(ExceptionContext filterContext)
But if I make a type in my view page, or enter a route that doesn't exist, it doesn't seem to log that erorr?
I am logging errors in my controllers method:
protected override void OnException(ExceptionContext filterContext)
But if I make a type in my view page, or enter a route that doesn't exist, it doesn't seem to log that erorr?
Use Elmah logging for that. No code required, just configuration. Elmah logs errors automatically in memory, xml, or a database, and provides a very nice userinterface for reviewing the errors.
See Scott Hanselman's explanation, and the official documentation, Using Elmah with ASP.NET MVC
Thats because its a pipeline and you want to log at a different scope, to log this error add the following to your global.asax:
public override void Init()
{
base.Error+=new EventHandler(MvcApplication_Error);
base.Init();
}
The pipeline is basically this:
so you need to get your error handlers in place before routing takes place to catch them.