customErrors

Discussion in 'ASP .Net' started by poifull, May 14, 2007.

  1. poifull

    poifull Guest

    Hi all,

    I specified an aspx page in my web.config/customErrors tag to handle any
    error that might occur.
    When an exception is thrown, Server.GetLastError() returns null in the error
    handling page. Please let me know if my approach is wrong.

    Web.config:
    <customErrors defaultRedirect="ShowErrorMessage.aspx" mode="On" />


    ShowErrorMessage.aspx:

    protected void Page_Load(object sender, EventArgs e)
    {

    Response.Write(Server.GetLastError() == null); // prints True

    }


    Thanks in advance.
    poifull, May 14, 2007
    #1
    1. Advertising

  2. Server.GetLastError() gets exception details only in Page_Error and
    Application_Error (if the error was not cleared in Page_Error). If you need
    the exception details in the custom error's default redirect page, store the
    exception in an application variable and access it in the custom error page
    (without calling Server.ClearError in Application_Error and Page_Error).


    "poifull" wrote:

    > Hi all,
    >
    > I specified an aspx page in my web.config/customErrors tag to handle any
    > error that might occur.
    > When an exception is thrown, Server.GetLastError() returns null in the error
    > handling page. Please let me know if my approach is wrong.
    >
    > Web.config:
    > <customErrors defaultRedirect="ShowErrorMessage.aspx" mode="On" />
    >
    >
    > ShowErrorMessage.aspx:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    >
    > Response.Write(Server.GetLastError() == null); // prints True
    >
    > }
    >
    >
    > Thanks in advance.
    >
    >
    >
    >
    =?Utf-8?B?U2l2YSBN?=, May 15, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NRao

    customErrors 404

    NRao, Jul 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    471
    Bassel Tabbara [MSFT]
    Jul 1, 2003
  2. Jesse Napier

    CustomErrors statusCode 500

    Jesse Napier, Aug 7, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    4,763
    Michal A. Valasek
    Aug 7, 2003
  3. =?Utf-8?B?cmV6YQ==?=

    <customErrors .... not working??

    =?Utf-8?B?cmV6YQ==?=, Feb 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    987
    Jim Cheshire [MSFT]
    Feb 18, 2004
  4. Pete Davis

    customErrors issues

    Pete Davis, Mar 2, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    389
    Pete Davis
    Mar 6, 2004
  5. =?Utf-8?B?U2FtdWVs?=

    .NET question about the customErrors Tag

    =?Utf-8?B?U2FtdWVs?=, May 2, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    457
    Steven Cheng[MSFT]
    May 11, 2004
Loading...

Share This Page