This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| new HandleErrorAttribute | |
| { | |
| View = "SomeView", | |
| ExceptionType = typeof (SomeException) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DerivedHandleErrorAttribute : HandleErrorAttribute | |
| { | |
| public override void OnException(ExceptionContext filterContext) | |
| { | |
| base.OnException(filterContext); | |
| if (context.ExceptionHandled) | |
| { | |
| // Log filterContext.Exception in some way. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filterContext.HttpContext.Response.Clear(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filterContext.HttpContext.Response.ClearHeaders(); | |
| filterContext.HttpContext.Response.ClearContent(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Application_Error(object sender, EventArgs e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ErrorHandlerHttpModule : IHttpModule | |
| { | |
| public void Init(HttpApplication context) | |
| { | |
| context.Error += Application_Error; | |
| } | |
| private static void Application_Error(object sender, EventArgs e) | |
| { | |
| // Error handling code goes here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <system.web> | |
| <!-- Additional configuration elided. --> | |
| <httpModules> | |
| <add | |
| name="ErrorHandlerHttpModule" | |
| type="MvcErrorHandling.MvcHelpers.ErrorHandlerHttpModule, MvcErrorHandling" /> | |
| </httpModules> | |
| </system.web> | |
| <system.webServer> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var exception = HttpContext.Current.Server.GetLastError(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var httpException = exception as HttpException; | |
| ... | |
| var statusCode = httpException.GetHttpCode(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HttpContext.Current.Server.ClearError(); |