Logging errors in asp.net mvc, OnException method not enough?

Logging errors in asp.net mvc, OnException method not enough?

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?

mvc ajax.actionlink with jquery dialog confirm


Asp.net mvc return data from codebehind of aspx page
Use Elmah logging for that.

how to use jquerydate picker with partial views in asp.net mvc?
No code required, just configuration.

Thoughts on writing a “flexible” API?
Elmah logs errors automatically in memory, xml, or a database, and provides a very nice userinterface for reviewing the errors..
How to get current route information in OnActionExecuting
See Scott Hanselman's explanation, and the official documentation, Using Elmah with ASP.NET MVC.
Need advice on multitab form in ASP.NET MVC

I set a property in my custom controller wrapper in OnActionExecuting, how to pass to Site.Master?

Using DataAnnotations 4.0


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:.
  1. incomming request
  2. Hits IIS/ ASP.net
  3. then the routing engine
  4. then the controllers
  5. then the views
so you need to get your error handlers in place before routing takes place to catch them..

82 out of 100 based on 72 user ratings 1222 reviews