473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with Server.GetLastError!

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


Nov 18 '05 #1
2 2111
Hi,
Check whether Server.GetLastError() returns any error object before
accessing its properties.

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:OD**************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #2
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" <sh******@online.excite.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
Check whether Server.GetLastError() returns any error object before
accessing its properties.

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:OD**************@TK2MSFTNGP12.phx.gbl...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ad | last post by:
I use GenericErrorPage.aspx for the redirect page when some error occur. I want to show some different according error statusCode . How can I get error statusCode form Server.GetLastError()?
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
21
by: Gary | last post by:
When using an ASPX page for a DefaultRedirect it does not work if the ASPX page has any code in it. If I put ... If Not IsPostBack Then lblMessage.Text = Server.GetLastError.Message End If ...
18
by: amdishigh | last post by:
We are experiencing the following problems concerning ASP.NET: our ASP.NET application, written in .NET 1.1 platform, and hosted in IIS 5.0 environment, experience frequent session timeout problem....
6
by: José Joye | last post by:
Hello, I'm currently reading the MS Developing Web applications with c# (and VB.net). In the chapter related to Error management, there is a sample about "Page-Level Error Pages" eg: In my...
4
by: Michael | last post by:
Using some example code I've found, I'm trying to do the custom error page thing. I have the following in global.asax.. Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Dim...
4
by: VK | last post by:
Hello, I am trying to get the last occured error via the following code: Sub Page_Load(...) Dim zero As Integer = 0 Try Dim err As Integer = 10 / zero Catch ex As Exception
7
by: jtfaulk | last post by:
I need to encode some information on the server side using ASP.NET with C#; sending via HTTP to a client side application, that needs to be decoded in an MFC C++ application. I'm not sure if I...
6
by: Blasting Cap | last post by:
I'm trying to convert a 1.1 app to 2.0, and keep finding one thing after another that either Framework 2.0 or Visual Studio 2005 doesn't like. Now this - In the global.asax, code that has been...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.