Solved

retrieving Server.GetLastError

Posted on 2002-05-29
4
195 Views
Last Modified: 2007-12-19
apparently, the <customErrors> feature of web.config flushes the contents of Server.GetLastError.

so on whatever error page the user gets redirected to, that page cannot display the contents of Server.GetLastError!

am i correct in saying this, or is there a way around this so i can capture the contents of Server.GetLastError?

or maybe i am doing something wrong?

thanks...
0
Comment
Question by:loyaliser
  • 2
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 100 total points
ID: 7042795
loyaliser,
You are not doing anything wrong. I came across this problem few months ago. I reported it to MS but nver got any reponse from them. It very well could be a bug. FOr now you can make sure that you provide try/catch handler arounf every call that is capable of throwing exceptio. And catch the exeptions there and then redirect the user to proper error page. And for HTTP 400 code sereies you will add <error> tag under <customErrors> and then you get redirected there.
Other than that, there is nosolution I have found so far.

Naveen
0
 
LVL 1

Author Comment

by:loyaliser
ID: 7042819
well, the only solution i can think of is to use the Application_Error method in Global.asax.

capture the Server.GetLastError data... do whatever you need to with it, then force a redirect to a standard error page (e.g. AllErrors.aspx), and within that page handle the type of error that occured by reading the URL variables (can send them through the redirect when it happens).

the only thing that i dislike about this method is that it prevents you from using the "cool" <customErrors> tag feature.

which i guess is not much of a big deal...

this leads to a QUESTION:

how can you capture the HTTP error code (e.g. 400, 500 etc.) that occured in Application_Error?

is there another Server method for that?

thanks...
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7042857
These errors have nothing to do with ASP.Net or ASP. 500 series errors are ASP specific errors. they don't get thrown in ASP.Net pages. You will get exceptions and that your handling in Application_error. For HTTP status errors, you have to rely on <error> redirections or if your application has specific requirements for these errors, then you will writr your own ISAPI filter and then handle it there.
0
 
LVL 1

Author Comment

by:loyaliser
ID: 7042869
the plot thickens... thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now