ericnet
Programmer
- Mar 29, 2006
- 106
I know that "Server.GetLastError()" returns an object of type Exception, and it is (more or less) the whole wrapped package of the last exception. While GetBaseException() returns the exception that is the root cause of one or more subsequent exceptions, so the original exception that caused the problem. But..
Which is the difference between detecting, logging and reporting exception information using "Server.GetLastError()" or without it? If I don’ t use it I will not get the last error?
So, for example, which is the difference between this way?:
And this way?:
Is the first way, using Server.GetLastError(), for use it only in Application_Error Subroutine in global.asax file? And what about GetBaseException()? When to use it?
Thanks
Which is the difference between detecting, logging and reporting exception information using "Server.GetLastError()" or without it? If I don’ t use it I will not get the last error?
So, for example, which is the difference between this way?:
Code:
[b]Dim ex As Exception = Server.GetLastError().GetBaseException()[/b]
EventLog.WriteEntry("Test Web", "Message: " & ex.Message & _
"\nSOURCE: " & ex.Source & "\nTARGETSITE: " & ex.TargetSite & _
"\nSTACKTRACE: " & ex.StackTrace, _ etc,..
Code:
[b]Dim ex As Exception[/b]
EventLog.WriteEntry("Test Web", "Message: " & ex.Message & _
"\nSOURCE: " & ex.Source & "\nTARGETSITE: " & ex.TargetSite & _
"\nSTACKTRACE: " & ex.StackTrace, _ etc,..
Is the first way, using Server.GetLastError(), for use it only in Application_Error Subroutine in global.asax file? And what about GetBaseException()? When to use it?
Thanks