Solved

retrieving Server.GetLastError

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

17 Experts available now in Live!

Get 1:1 Help Now