Problem with Server.GetLastError!

Discussion in 'ASP .Net' started by Lars Netzel, Aug 2, 2004.

  1. Lars Netzel

    Lars Netzel Guest

    I'm trying to make my own custom error page... but when using
    Try

    lblErrormessage.Text = Server.GetLastError.Message

    lblErrormessage.Text += "<br>" & Server.GetLastError.StackTrace

    lblErrormessage.Text += "<br>" & Server.GetLastError.Source

    Catch ex As Exception

    lblErrormessage.Text = ex.Message

    End Try

    It goes into the Catch and says "Object reference not set to an instance of
    an object." I have debugged alittle and Server is avaliable.. but
    GetLastError gives the error..

    Do I need to enable something in order to use this?

    Regards/Lars Netzel
    Lars Netzel, Aug 2, 2004
    #1
    1. Advertising

  2. Lars Netzel

    Shiva Guest

    Hi,
    Check whether Server.GetLastError() returns any error object before
    accessing its properties.

    "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
    news:...
    I'm trying to make my own custom error page... but when using
    Try

    lblErrormessage.Text = Server.GetLastError.Message

    lblErrormessage.Text += "<br>" & Server.GetLastError.StackTrace

    lblErrormessage.Text += "<br>" & Server.GetLastError.Source

    Catch ex As Exception

    lblErrormessage.Text = ex.Message

    End Try

    It goes into the Catch and says "Object reference not set to an instance of
    an object." I have debugged alittle and Server is avaliable.. but
    GetLastError gives the error..

    Do I need to enable something in order to use this?

    Regards/Lars Netzel
    Shiva, Aug 2, 2004
    #2
    1. Advertising

  3. Lars Netzel

    Lars Netzel Guest

    No I figured it out..

    Since you are redirected to another errorpage you loose the GetLatsetError
    information, cause you are not on that page anymore.. BUT.. if you in
    Global.aspx in Page_error event (where it's still accessible) put
    Server.GetLastError in a SESSION variable.. you can get it thru that on the
    Errorpage ..

    /Lars


    "Shiva" <> skrev i meddelandet
    news:%...
    > Hi,
    > Check whether Server.GetLastError() returns any error object before
    > accessing its properties.
    >
    > "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
    > news:...
    > I'm trying to make my own custom error page... but when using
    > Try
    >
    > lblErrormessage.Text = Server.GetLastError.Message
    >
    > lblErrormessage.Text += "<br>" & Server.GetLastError.StackTrace
    >
    > lblErrormessage.Text += "<br>" & Server.GetLastError.Source
    >
    > Catch ex As Exception
    >
    > lblErrormessage.Text = ex.Message
    >
    > End Try
    >
    > It goes into the Catch and says "Object reference not set to an instance

    of
    > an object." I have debugged alittle and Server is avaliable.. but
    > GetLastError gives the error..
    >
    > Do I need to enable something in order to use this?
    >
    > Regards/Lars Netzel
    >
    >
    >
    >
    >
    Lars Netzel, Aug 2, 2004
    #3
    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. Christopher

    Server.GetLastError() return null

    Christopher, Jul 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,617
    terry
    Jul 2, 2003
  2. Dave

    Server.GetLastError()

    Dave, Dec 1, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    357
  3. José Joye
    Replies:
    6
    Views:
    2,523
    José Joye
    Aug 4, 2004
  4. =?Utf-8?B?RGFuaWVsIFdpbGxpYW1z?=

    Server.GetLastError() in a Web Farm

    =?Utf-8?B?RGFuaWVsIFdpbGxpYW1z?=, Dec 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    502
    Karl Seguin
    Dec 15, 2004
  5. tshad
    Replies:
    0
    Views:
    794
    tshad
    Jan 27, 2005
Loading...

Share This Page