473,468 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Custom Errors Not Working

I posted this question about a week or so ago. I never got any replies so
please forgive me if you have already read this question.

I have the following in my web config file:

<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" />

Here is the code in the Error.aspx:

protected void Page_Load(object sender, EventArgs e)
{
Exception err = Server.GetLastError().GetBaseException();

this.lblMessage.Text = err.ToString();
}

If mode is set to RemoteOnly I still get the yellow screen of death.
If mode is set to Off I still get the yellow screen of death.
If mode is set to On I get the yellow screen of death that tells me to set
the mode to RemoteOnly or Off to see the actual error message.

Why the heck doesn't it direct to my Error.aspx page and show the error that
way?
--
-Demetri
Aug 23 '06 #1
4 5278
re:
Why the heck doesn't it direct to my Error.aspx page and show the error that way?
Any unhandled exception is captured by Application_Error.

What does your Application_Error sub/void in global.asax have ?

You should have something like :

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("Error.aspx")
End Sub

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Demetri" <De*****@discussions.microsoft.comwrote in message
news:A9**********************************@microsof t.com...
>I posted this question about a week or so ago. I never got any replies so
please forgive me if you have already read this question.

I have the following in my web config file:

<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" />

Here is the code in the Error.aspx:

protected void Page_Load(object sender, EventArgs e)
{
Exception err = Server.GetLastError().GetBaseException();

this.lblMessage.Text = err.ToString();
}

If mode is set to RemoteOnly I still get the yellow screen of death.
If mode is set to Off I still get the yellow screen of death.
If mode is set to On I get the yellow screen of death that tells me to set
the mode to RemoteOnly or Off to see the actual error message.

Why the heck doesn't it direct to my Error.aspx page and show the error that
way?
--
-Demetri

Aug 23 '06 #2
The Application_Error sub/void in global.asax has nothing. I didn't think it
needed any code since the customErrors section has an attribute for the
defaultRedirect, what is the point in this if I still need to write code to
do it in the Application_Error method?

Examples i've seen from Microsoft did not elude to having to do that.

-Demetri
"Juan T. Llibre" wrote:
re:
Why the heck doesn't it direct to my Error.aspx page and show the error that way?

Any unhandled exception is captured by Application_Error.

What does your Application_Error sub/void in global.asax have ?

You should have something like :

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("Error.aspx")
End Sub

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Demetri" <De*****@discussions.microsoft.comwrote in message
news:A9**********************************@microsof t.com...
I posted this question about a week or so ago. I never got any replies so
please forgive me if you have already read this question.

I have the following in my web config file:

<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" />

Here is the code in the Error.aspx:

protected void Page_Load(object sender, EventArgs e)
{
Exception err = Server.GetLastError().GetBaseException();

this.lblMessage.Text = err.ToString();
}

If mode is set to RemoteOnly I still get the yellow screen of death.
If mode is set to Off I still get the yellow screen of death.
If mode is set to On I get the yellow screen of death that tells me to set
the mode to RemoteOnly or Off to see the actual error message.

Why the heck doesn't it direct to my Error.aspx page and show the error that
way?
--
-Demetri


Aug 23 '06 #3
re:
what is the point in this if I still need to write code to
do it in the Application_Error method?
Examples i've seen from Microsoft did not elude to having to do that.
Hi, Demetri.

No offense, but you need to get your hands dirty with exception handling.
There's a lot more to this than you think there is.

There's plain Exceptions and there's Unhandled Exceptions.
They're handled via different methods.

Check out Peter Bromberg's excellent article on Unhandled Exceptions :
http://www.eggheadcafe.com/articles/20060305.asp

Also, check out this KB :
http://support.microsoft.com/?id=911816

....and, for good measure, see this Code Project article :
http://www.codeproject.com/aspnet/AS...onHandling.asp


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Demetri" <De*****@discussions.microsoft.comwrote in message
news:22**********************************@microsof t.com...
The Application_Error sub/void in global.asax has nothing. I didn't think it
needed any code since the customErrors section has an attribute for the
defaultRedirect, what is the point in this if I still need to write code to
do it in the Application_Error method?

Examples i've seen from Microsoft did not elude to having to do that.

-Demetri
"Juan T. Llibre" wrote:
>re:
Why the heck doesn't it direct to my Error.aspx page and show the error that way?

Any unhandled exception is captured by Application_Error.

What does your Application_Error sub/void in global.asax have ?

You should have something like :

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("Error.aspx")
End Sub

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Demetri" <De*****@discussions.microsoft.comwrote in message
news:A9**********************************@microso ft.com...
>I posted this question about a week or so ago. I never got any replies so
please forgive me if you have already read this question.

I have the following in my web config file:

<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" />

Here is the code in the Error.aspx:

protected void Page_Load(object sender, EventArgs e)
{
Exception err = Server.GetLastError().GetBaseException();

this.lblMessage.Text = err.ToString();
}

If mode is set to RemoteOnly I still get the yellow screen of death.
If mode is set to Off I still get the yellow screen of death.
If mode is set to On I get the yellow screen of death that tells me to set
the mode to RemoteOnly or Off to see the actual error message.

Why the heck doesn't it direct to my Error.aspx page and show the error that
way?
--
-Demetri



Aug 23 '06 #4
Demetri,

the problem is that the error page is displayed by using re-direction,
that means that when you get into the page handler for the error page
the exception has disappeared. Calling

Exception ex = Server.GetLastError().GetBaseException()

itself raises a null reference exception, because Server.GetLastError()
returns null (put a breakpoint here and see for yourself).

The way to handle this (as somebody mentioned) is to add an
Application_Error handler and in there either: Server.Transfer to
Error.aspx; or save the exception in the session and then in error.aspx
retrieve the exception from the session.

HTH

Kevin Jones

Demetri wrote:
I posted this question about a week or so ago. I never got any replies so
please forgive me if you have already read this question.

I have the following in my web config file:

<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" />

Here is the code in the Error.aspx:

protected void Page_Load(object sender, EventArgs e)
{
Exception err = Server.GetLastError().GetBaseException();

this.lblMessage.Text = err.ToString();
}

If mode is set to RemoteOnly I still get the yellow screen of death.
If mode is set to Off I still get the yellow screen of death.
If mode is set to On I get the yellow screen of death that tells me to set
the mode to RemoteOnly or Off to see the actual error message.

Why the heck doesn't it direct to my Error.aspx page and show the error that
way?

Aug 24 '06 #5

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

Similar topics

3
by: Mark Metzner | last post by:
We currently have custom error logging setup on all of our websites. We have IIS setup to redirect to our custom 500-100.asp page which logs the error to a database and then redirects to a...
16
by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are...
1
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI...
4
by: Jon Spivey | last post by:
Hi, I've set up a custom error like this <customErrors mode="On" defaultRedirect="ErrorPage.aspx"> <error statusCode="404" redirect="error404.aspx" /> </customErrors> So requests for...
2
by: Matt | last post by:
Hello all, The app we are working on uses custom errors extensively to provide friendly error pages to users whilst logging the actual exceptions behind the scenes. However.... We are now...
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...
3
by: Greg Collins [Microsoft MVP] | last post by:
I have done a bit of research of Url Rewriting, but as yet have been unsuccessful at getting it to work well, and there are issues around what file types are supported and how much code you want to...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
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...
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,...
1
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.