Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I added 2 kinds of error handling to my code:

 

In web.config , i have this

 

<customErrors  defaultRedirect="ApplicationError.htm" mode="RemoteOnly" >
    <error statusCode="403" redirect="pages\Forbidden.htm"/>
    <error statusCode="404" redirect="NotFound.htm"/>
   
   </customErrors>

 

In Global.asax , I have this to log to even viewer:

 

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
       ' Fires when an error occurs
       Dim unhandledException As Exception = Server.GetLastError().InnerException
       If Not EventLog.SourceExists("ESPWebClient") Then
           EventLog.CreateEventSource("ESPWebClient", "ESPWebClient Log")
       End If

       Dim el As EventLog = New EventLog()
       el.Source = "ESPWebClient"
       el.WriteEntry("An exception occured: Created an entry in the event log")
       'Server.ClearError()

   End Sub

 

I got an unhandeled error, But instead of loging to event viewer, the Custom Error in WebConfig popped up

 

Why didnt the application error in Global.asax fire??

Posted

use either one of the ways, either remove the custom errors and place the redirections in global.asax or remove the application_error event

they both do the same job

Posted

they both do the same job ...

 

No, i think they're different...

 

The Application_Error takes care of overall Application unhandled errors... So i think in this case, i think application_error should've fired..

 

 

I'm still not sure why, how the custom error fired ??

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...