Solved

retrieving Server.GetLastError

Posted on 2002-05-29
4
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 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