In each action, I write:
public ActionResult Foo()
{
try
{
// Do something
}
catch(Exception ex)
{
Logger.Error("Foo()", ex);
}
...
}
I know MVC3 has the ability to “RegisterGlobalFilters” in Global.asax, so I want to write a custom LogExceptionAttribute. which will:
-
Log information of which Action cause what Exception. calling my Logger API:
Logger.Error(string actionName, Exception ex)
-
throw the exception again. so that CustomError in web.config will show user error page.
How to implement this?
Try this