I just posted a new article to CodeProject, User Friendly ASP.NET Exception Handling.
This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2004/08/user-friendly-aspnet-exception-handling.html
I just posted a new article to CodeProject, User Friendly ASP.NET Exception Handling.
I added code for custom errors support in web.config.
Please check it. If you like,please add to your code project article.
Protected Overridable Sub OnError(ByVal sender As Object, ByVal args As EventArgs)
Dim app As HttpApplication = CType(sender, HttpApplication)
If InStr(app.Server.GetLastError.Message, “The file”) 0 And InStr(app.Server.GetLastError.Message, “does not exist”) 0 Then
Dim ueh As New Handler
ueh.SaveExceptionToLogFile(app.Server.GetLastError)
app.Server.ClearError()
Dim virtualPath As String = Sahin.Diagnostics.Errorlog.Config.GetString("AppPath")
Dim config As Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(virtualPath)
Dim cusErr As Web.Configuration.CustomErrorsSection
cusErr = CType(config.SectionGroups("system.web").Sections("customErrors"), Web.Configuration.CustomErrorsSection)
If cusErr.Mode = Web.Configuration.CustomErrorsMode.On Then
For Each err As System.Web.Configuration.CustomError In cusErr.Errors
If err.StatusCode = 404 Then
app.Response.Redirect(err.Redirect)
End If
Next
End If
Else
Dim ueh As New Handler
ueh.HandleException(app.Server.GetLastError)
End If
End Sub