I am working on a MVC3 razor application. I have created a error Handling functionality to log the un-handled exceptions. As bellow:
public class ErrorHandlingAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext context)
{
base.OnException(context);
LogException(context);
}
}
On each controller I just need to add the error handler as bellow:
[ErrorHandlingAttribute]
public class HomeController : Controller
It logging the errors but some how its hitting the OnException method twice. And then it writes the duplicate log.
Can anyone suggest me what its happening.
Many thanks
You should remove the default
HandleErrorattribute that is registered by default in yourGlobal.asax. You could replace it with your custom attribute.