473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error details in Custom Error Page

Hi,

I have created a custom error page for my web application (c#, .Net 2)
In this page I am trying to get the details of the error that has
occurred so that I can display it if required.

(Error page defined in Web.config)

I am using the following code:

HttpContext ctx = HttpContext.Current;
Exception ex = ctx.Server.GetLastError();

This always appears to return null for the exception.
How can I get the details of the exception that occurred that caused my
error page to be displayed?
Thankyou.
Paul
Feb 16 '07 #1
3 2006
Paul,

I was posting another issue here and I noticed this thread. I tried the
same thing and had the same problem and I never found an answer. If you get
an answer on you own please post it here.

Thanks,

--
Thanks,

Bill Manring
Wavefront Software, Inc.
"Paul Cheetham" wrote:
Hi,

I have created a custom error page for my web application (c#, .Net 2)
In this page I am trying to get the details of the error that has
occurred so that I can display it if required.

(Error page defined in Web.config)

I am using the following code:

HttpContext ctx = HttpContext.Current;
Exception ex = ctx.Server.GetLastError();

This always appears to return null for the exception.
How can I get the details of the exception that occurred that caused my
error page to be displayed?
Thankyou.
Paul
Feb 16 '07 #2
Normally you would have this code in Application_Error in global.asax.
Server.GetLastError().GetBaseException will return the true innerException
containing the error message.

Not sure if you need to but if you tried to do this on your custom error
page, and it was already retrieved in Application_Error, you might need to
store it in Session or Cache so that you can redisplay on your custom error
page. This will be especially true if you call Server.ClearError() after
getting the exception.

However, you might want to consider the security implications of displaying
exception information like this to the "public" on your site.
Peter

Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Paul Cheetham" wrote:
Hi,

I have created a custom error page for my web application (c#, .Net 2)
In this page I am trying to get the details of the error that has
occurred so that I can display it if required.

(Error page defined in Web.config)

I am using the following code:

HttpContext ctx = HttpContext.Current;
Exception ex = ctx.Server.GetLastError();

This always appears to return null for the exception.
How can I get the details of the exception that occurred that caused my
error page to be displayed?
Thankyou.
Paul
Feb 16 '07 #3

I've not got any Page_Error or Application_Error handlers defined, and
so was expecting the full error details to be available to me.

I'm not worried about the security, as it's an Intranet site, and we
have a seting to turn detiled error reporting on and off for debugging
purposes.
Paul
Peter Bromberg [C# MVP] wrote:
Normally you would have this code in Application_Error in global.asax.
Server.GetLastError().GetBaseException will return the true innerException
containing the error message.

Not sure if you need to but if you tried to do this on your custom error
page, and it was already retrieved in Application_Error, you might need to
store it in Session or Cache so that you can redisplay on your custom error
page. This will be especially true if you call Server.ClearError() after
getting the exception.

However, you might want to consider the security implications of displaying
exception information like this to the "public" on your site.
Peter

Peter
Feb 17 '07 #4

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

Similar topics

6
by: Javier Cortés Cortés | last post by:
i am getting this error when i am trying to access any file(with the ext. aspx) from my remote server. the error is : Server Error in '/' Application....
3
by: Damian | last post by:
Hi everyone I'm having an issue with one of our applications. I'm getting the following error when attempting to log in to the site: Server Error in 'xxxxxxxxxxxxxxxx' Application....
4
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
3
by: Sean | last post by:
HI There, I am having trouble deploying my .aspx pages to a remote server, I have made changes to the config file and it still returns an error. I have also contacted the server administrator to...
0
by: Adam Getchell | last post by:
I'm attempting to write a custom Authentication module using http://www.15seconds.com/Issue/020417.htm I looked at http://support.microsoft.com/default.aspx?scid=kb;EN-US;307996, but it doesn't...
0
by: Rhys666 | last post by:
OK, an issue I've come across before, but never found a cause for or resolution of, has decided to become the bane of my life again with ASP.Net Custom Error Pages. Basically, my web application...
6
by: dee | last post by:
Hi In web.config I have to the following: <configuration> <system.web> <customErrors defaultRedirect="error.htm" mode="On" /> </system.web> </configuration>
4
by: Pat | last post by:
In my Web.config i have :- <customErrors mode="On" defaultRedirect="genericerror.htm"> <error statusCode="404" redirect="pagenotfound.aspx"/> </customErrors to get page not found error but...
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.