locked
default redirect page not displayed for exception in global.asax Application_BeginRequest RRS feed

  • Question

  • User1258842765 posted

    If an exception is thrown in Application_BeginRequest(), would .net display the "defaultRedirect" page or just display the "Runtime Error" message asking me to change my custom error settings? I keep getting the Runtime Error message with the following setting:

    <customErrors mode="On" defaultRedirect="~/ErrorPages/Error.aspx">
    </customErrors>

    Update: Running IIS7 and application pool is in classic mode.


    Thanks.

    Monday, April 8, 2013 5:32 PM

Answers

  • User1258842765 posted

    After some digging i found that the Error.aspx was inheriting from a base page that relied on application variables set in Application_BeginRequest. This would cause the cutom error page to never show. I'm redirecting any errors in the Appliation_BeginRequest to a html page using Server.Transfer and that works for me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 9, 2013 1:26 PM

All replies

  • User533502567 posted

    keep getting the Runtime Error message with the following setting:

    What's the error message you are getting? For IIS7 or above, add (From MSDN)

    Response.TrySkipIisCustomErrors = true;

    to Page_Load of Error.aspx

    Monday, April 8, 2013 6:28 PM
  • User1258842765 posted

    Thanks but that didn't help. The error i'm getting is not an IIS7 error, it's a .net error. See below.

    I guess my bigger question is does the customErrors setting in web.config handle errors generated from application events?

    --------------------------------------

    Server Error in '/*******' Application.


    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. 

    Details: To enable the details of this specific error message to be viewable on the local server machine, 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 "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".

    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="RemoteOnly"/>
        </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="On" defaultRedirect="mycustompage.htm"/>
        </system.web>
    </configuration>

    Tuesday, April 9, 2013 9:15 AM
  • User1258842765 posted

    After some digging i found that the Error.aspx was inheriting from a base page that relied on application variables set in Application_BeginRequest. This would cause the cutom error page to never show. I'm redirecting any errors in the Appliation_BeginRequest to a html page using Server.Transfer and that works for me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 9, 2013 1:26 PM