473,722 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue with GetLastError() in Passing Application_Err or to Custom Error Page

I am having issues with a production server with the GetLastError()
method. Here is what I am doing:

Application_Err or on Global ASAX:

Note: I am doing it this way (with ClearError) because while
researching, someone on a post said that Session state would not
persist unless I cleared the error... didn't make sense, but it also
didn't work before I put this in there too.

Exception ex = Server.GetLastE rror();
Server.ClearErr or();
Session["LastError"] = ex;
Response.Redire ct("CustomError Page.aspx");

Then, on the Custom Error Page:

Exception ex = (Exception)Sess ion["LastError"];
// displaying and emailing exception details

On my developer machine, this works just fine, but on the production
server the Session["LastError"] ALWAYS returns null. As a result, I
cannot get to any of the exception details. I also tried doing all of
this in the global asax, but there the GetLastError() is STILL null!
Makes no sense to me how on the Application_Err or method the first line
of code is GetLastError() and it returns null. Any ideas?

Nov 19 '05 #1
1 2441
I think you're clearing the error before you've placed it into a threadsafe
object.

In other words Server.ClearErr or(); is getting rid of the object stored in
Session also.

Try placing the error text into a string first such as:

String ex = Server.GetLastE rror().ToString ;

Session["LastError"] = ex;

Then change ex on your custom error page to a string. (The string will
contain all the error text...)

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

<ro********@gma il.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
I am having issues with a production server with the GetLastError()
method. Here is what I am doing:

Application_Err or on Global ASAX:

Note: I am doing it this way (with ClearError) because while
researching, someone on a post said that Session state would not
persist unless I cleared the error... didn't make sense, but it also
didn't work before I put this in there too.

Exception ex = Server.GetLastE rror();
Server.ClearErr or();
Session["LastError"] = ex;
Response.Redire ct("CustomError Page.aspx");

Then, on the Custom Error Page:

Exception ex = (Exception)Sess ion["LastError"];
// displaying and emailing exception details

On my developer machine, this works just fine, but on the production
server the Session["LastError"] ALWAYS returns null. As a result, I
cannot get to any of the exception details. I also tried doing all of
this in the global asax, but there the GetLastError() is STILL null!
Makes no sense to me how on the Application_Err or method the first line
of code is GetLastError() and it returns null. Any ideas?

Nov 19 '05 #2

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

Similar topics

1
1648
by: SilverlineDesign | last post by:
I am having trouble using Server.GetLastError() on my asp.net pages. I defines a standard error page in my web.config to handle all site errors, but the page that is supposed to handle the error creates an error itself. Whenever I try to retrieve the last made error with Server.GetLastError() will retrieve a null result, so if I try to print out something like Server.GetLastError().ToString() the page will spit out a nullreference exception....
3
8309
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()?
1
7994
by: Christopher | last post by:
Try using the Application_Error() event in Global.asax. The context of the error will be available here. Your application is handling the error, and thus there is no LastError to Get. hth, -Christopher http://weblogs.asp.net/CFrazier
1
2408
by: Dave | last post by:
Hi I want to know if it's possible to user Server.GetLastError() in my AppError.aspx below? The GetLastError is not available here and returns null. I'm using Application_Error event to send an email, but I also want to create a custom error page in the AppError.aspx that displays some of the error message. Do I have to preserve the error message in the Application_Error event <customErrors mode="On" defaultRedirect="AppError.aspx"/> ...
6
4603
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 form: ========
4
4129
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
6
4566
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error if you are already capturing errors in Application_Error? Also, if you have any links to discussions about when to use which function it would be helpful.
2
12209
by: Seguros Catatumbo | last post by:
Hello guys, i am trying to port my custom asp 3.0 error page to asp.net. I want to disable debugging in my asp.net projects but i want to show the users a pretty page but that page should send me an email with the details of the error. On classic asp i just went to iis and mapped the 500 error code to error.asp, which does this: set objError = Server.getLastError()
1
1896
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
I have a web app that handles errors in the Gloabal.ascx's Application_Error(). It does some logging etc in there and if it throws an error, I want the app to display a static html splash page rather than a yellow screen asp.net error. I have tried setting the custom error page and also a try catch in the application_error with a server.transfer in the catch but it always seems to go to a yellow screen asp.net error page (without any...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.