nphoenix
asked on
Global error handling - customErrors mode="RemoteOnly" defaultRedirect="errorhandler.aspx"
Can i set <customErrors mode="RemoteOnly" defaultRedirect="errorhand ler.aspx"> in my web.config, and then in ="errorhandler.aspx" i want to email my self the error. But even loading alabel control with the error that took me to the page (errorhandler.aspx) is causing me an issue.
Can i do something like
Imports System.Diagnostics
Dim ex As Exception = Server.GetLastError().GetB aseExcepti on()
label1.text = ex.message ???
This gives me - Object reference not set to an instance of an object.
Can i do something like
Imports System.Diagnostics
Dim ex As Exception = Server.GetLastError().GetB
label1.text = ex.message ???
This gives me - Object reference not set to an instance of an object.
ASKER
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept ion: Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept
ASKER
but i am running the page (with no error present) as a test directly... is that why its null?
ASKER
no - still an error when i access an intentionally broken page - and it rolls to errorhandler.aspx
How about if you try:
Dim ex As Exception
If Not Server.GetLastError() Is Nothing Then
ex = Server.GetLastError().GetB aseExcepti on()
(OR)
ex = New Exception(Server.GetLastEr ror().GetB aseExcepti on().Messa ge)
End If
Dim ex As Exception
If Not Server.GetLastError() Is Nothing Then
ex = Server.GetLastError().GetB
(OR)
ex = New Exception(Server.GetLastEr
End If
Does the old error object show anything?
Dim ex As Exception
On Error Resume Next
'Error Condition
If Err.Number <> 0 Then
'Does Err object show anything?
Dim ErrorDescription As String = Err.Description
On Error GoTo 0
Err.Clear
ex = New Exception(ErrorDescription )
End If
Dim ex As Exception
On Error Resume Next
'Error Condition
If Err.Number <> 0 Then
'Does Err object show anything?
Dim ErrorDescription As String = Err.Description
On Error GoTo 0
Err.Clear
ex = New Exception(ErrorDescription
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could you share the SQL code as well?
Thanks very much
Anthony.
Thanks very much
Anthony.
Dim ex As New Exception(Server.GetLastEr