Solved

retrieving Server.GetLastError

Posted on 2002-05-29
4
204 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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