R
Richard
I have been struggling with this for days. I feel I must be missing something simple, and I will be eternally grateful for any help. I'm using VS.NET 2003 on XP Pro Sp2.
I searched and found several examples of Custom Error pages for ASP.NET and nothing seemed to work. I zeroed in on "Server.GetLastError" and found it was always "Nothing".
This is in my web.config:
<customErrors mode="On" defaultRedirect="error/errors.aspx" />
In errors.aspx, I copied the code below exactly from MSDN "GetLastError Method" sample.
When I step through the code from an intentional 404 error, LastError is always "nothing". Any idea why? How do I get some useful error info so I can display a custom message for 404 errors, and something else for other errors.
'--- errors.aspx
Dim LastError As Exception
Dim ErrMessage As String
LastError = Server.GetLastError()
If Not LastError Is Nothing Then
ErrMessage = LastError.Message
Else
ErrMessage = "No Errors"
End If
Response.Write("Last Error = " & ErrMessage)
I searched and found several examples of Custom Error pages for ASP.NET and nothing seemed to work. I zeroed in on "Server.GetLastError" and found it was always "Nothing".
This is in my web.config:
<customErrors mode="On" defaultRedirect="error/errors.aspx" />
In errors.aspx, I copied the code below exactly from MSDN "GetLastError Method" sample.
When I step through the code from an intentional 404 error, LastError is always "nothing". Any idea why? How do I get some useful error info so I can display a custom message for 404 errors, and something else for other errors.
'--- errors.aspx
Dim LastError As Exception
Dim ErrMessage As String
LastError = Server.GetLastError()
If Not LastError Is Nothing Then
ErrMessage = LastError.Message
Else
ErrMessage = "No Errors"
End If
Response.Write("Last Error = " & ErrMessage)