You can also create a custom module called "ErrorHandlingModule" that will go into the HttpModule.
public class ErrorHandlingModule : IHttpModule
{
public void Init(HttpApplication application)
{
application.Error += new System.EventHandler(OnError);
}
public void OnError(object obj, EventArgs args)
{
Exception ex = HttpContext.Current.Server.GetLastError();
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Redirect("/Error.aspx", false);
}
}
It will look something like this.
source
share