T
tshad
This has been driving me crazy.
I have been trying to get the error handling working on my system and can
get parts of it working and others won't work at all.
I found that you can't access session variables from Application_Error
event, but I need to so I don't need to set up traces to see what they are
during an error. I am emailing the error condition to myself when it
happens.
So I moved the code to one of my error pages and it works fine if called
directly. So I added this code to my Application_Error routine:
Sub Application_Error(Sender As Object, E as EventArgs)
response.Redirect("/PageError.aspx")
End Sub
And it goes fine to my error page which emails my session variables to me,
but when I try to do:
Dim exception As Exception = Server.GetLastError()
I get nothing. I assume the Application_Error routine cleared it.
I then tried to comment out the Application_Error code so it would go to the
CustomErrors in my webconfig file:
<customErrors defaultRedirect="PageUnavailable.aspx" mode="Off" />
but the page is never called - it goes to the MS Error page. If Change mode
to "On",
<customErrors defaultRedirect="PageUnavailable.aspx" mode="On" />
I get the following page:
*********************************************************************
Runtime Error
Description: An application error occurred on the server. The current custom
error settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could, however,
be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable
on remote machines, please create a <customErrors> tag within a "web.config"
configuration file located in the root directory of the current web
application. This <customErrors> tag should then have its "mode" attribute
set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom
error page by modifying the "defaultRedirect" attribute of the application's
<customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
************************************************************************************
I also tried setting up a Page_Error in my program and it never gets called.
I don't understand why this is a problem.
Tom
I have been trying to get the error handling working on my system and can
get parts of it working and others won't work at all.
I found that you can't access session variables from Application_Error
event, but I need to so I don't need to set up traces to see what they are
during an error. I am emailing the error condition to myself when it
happens.
So I moved the code to one of my error pages and it works fine if called
directly. So I added this code to my Application_Error routine:
Sub Application_Error(Sender As Object, E as EventArgs)
response.Redirect("/PageError.aspx")
End Sub
And it goes fine to my error page which emails my session variables to me,
but when I try to do:
Dim exception As Exception = Server.GetLastError()
I get nothing. I assume the Application_Error routine cleared it.
I then tried to comment out the Application_Error code so it would go to the
CustomErrors in my webconfig file:
<customErrors defaultRedirect="PageUnavailable.aspx" mode="Off" />
but the page is never called - it goes to the MS Error page. If Change mode
to "On",
<customErrors defaultRedirect="PageUnavailable.aspx" mode="On" />
I get the following page:
*********************************************************************
Runtime Error
Description: An application error occurred on the server. The current custom
error settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could, however,
be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable
on remote machines, please create a <customErrors> tag within a "web.config"
configuration file located in the root directory of the current web
application. This <customErrors> tag should then have its "mode" attribute
set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom
error page by modifying the "defaultRedirect" attribute of the application's
<customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
************************************************************************************
I also tried setting up a Page_Error in my program and it never gets called.
I don't understand why this is a problem.
Tom