 <p>You can create a custom filter that inherits from FilterAttribute and implements IExceptionFilter. Then register it in global.asax.cs. Also you must enable custom errors handling in the web.config: </p> <pre><code>&lt;customErrors mode="On"/&gt; public class HandleErrorAndLogExceptionAttribute : FilterAttribute, IExceptionFilter { /// &lt;summary&gt; /// The method called when an exception happens /// &lt;/summary&gt; /// &lt;param name="filterContext"&gt;The exception context&lt;/param&gt; public void OnException(ExceptionContext filterContext) { if (filterContext != null &amp;&amp; filterContext.HttpContext != null) { if (!filterContext.IsChildAction &amp;&amp; (!filterContext.ExceptionHandled &amp;&amp; filterContext.HttpContext.IsCustomErrorEnabled)) { // Log and email the exception. This is using Log4net as logging tool Logger.LogError("There was an error", filterContext.Exception); string controllerName = (string)filterContext.RouteData.Values["controller"]; string actionName = (string)filterContext.RouteData.Values["action"]; HandleErrorInfo model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName); // Set the error view to be shown ViewResult result = new ViewResult { ViewName = "Error", ViewData = new ViewDataDictionary&lt;HandleErrorInfo&gt;(model), TempData = filterContext.Controller.TempData }; result.ViewData["Description"] = filterContext.Controller.ViewBag.Description; filterContext.Result = result; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; } } } </code></pre>