Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with Server.GetLastError!

Reply
Thread Tools

Problem with Server.GetLastError!

 
 
Lars Netzel
Guest
Posts: n/a
 
      08-02-2004
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




 
Reply With Quote
 
 
 
 
Shiva
Guest
Posts: n/a
 
      08-02-2004
Hi,
Check whether Server.GetLastError() returns any error object before
accessing its properties.

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:(E-Mail Removed)...
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





 
Reply With Quote
 
 
 
 
Lars Netzel
Guest
Posts: n/a
 
      08-02-2004
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" <(E-Mail Removed)> skrev i meddelandet
news:%(E-Mail Removed)...
> Hi,
> Check whether Server.GetLastError() returns any error object before
> accessing its properties.
>
> "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
> news:(E-Mail Removed)...
> 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
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments