By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Custom Error Handling Problem /Question

P: n/a
I'm testing error handling configurations and having some trouble. I created
a WebForm called. ErrDefault.aspx and I am trying to use the Page error
attribute to force the redirection to a custom page, but I only get and
unhandled exception page and it does not direct me to my specific page. I'm
probably doing something really stupid, but I cant see what .

Any Ideas ? - Thanx Mr N

--------- DETAILS BELOW -----------

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="Exceptions1.WebForm1" errorPage="ErrDefault.aspx"%>
In my button handler.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Throw New System.Net.WebException("Custom Error Page")

End Sub

Custom Error Page
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Net.WebException: Custom Error Page

Source Error:

Line 33:
Line 34: Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Line 35: Throw New System.Net.WebException("Custom Error Page")
Line 36: End Sub
Line 37: End Class

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You might want to download and check out the source code for
the "Error Handling in ASP.NET" Code Project article By Rakesh Rajan.

It shows how to manage several error handling configurations.

http://www.codeproject.com/aspnet/Er...lingASPNET.asp

You will need to become a member ( free ) of the Code Project
to be able to download any source code files from it, but they are
good about not hassling you or sending spam.

You can read the article without having to become a member, though.

Off hand :

1. Did you set up error handling in web.config and global.asax ?

web.config :
<customErrors mode="On" defaultRedirect="ErrDefault.aspx"/>

global.asax :
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("ErrDefault.aspx")
End Sub

2. What does "ErrDefault.aspx" do ?

I have web.config and global.asax setup that way,
and you can see the test page with your code, working OK, at :

http://asp.net.do/test/errorTest.aspx

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mr Newbie" <he**@now.com> wrote in message news:ub*************@TK2MSFTNGP10.phx.gbl...
I'm testing error handling configurations and having some trouble. I created a WebForm
called. ErrDefault.aspx and I am trying to use the Page error attribute to force the
redirection to a custom page, but I only get and unhandled exception page and it does
not direct me to my specific page. I'm probably doing something really stupid, but I
cant see what .

Any Ideas ? - Thanx Mr N

--------- DETAILS BELOW -----------

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="Exceptions1.WebForm1" errorPage="ErrDefault.aspx"%>
In my button handler.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click

Throw New System.Net.WebException("Custom Error Page")

End Sub

Custom Error Page
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where it
originated in the code.

Exception Details: System.Net.WebException: Custom Error Page

Source Error:

Line 33:
Line 34: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Line 35: Throw New System.Net.WebException("Custom Error Page")
Line 36: End Sub
Line 37: End Class

Nov 19 '05 #2

P: n/a
Thanks Jaun

I'll take a look tomorrow, its late right now and my brain has ceased
virtually all non automatic function.

Regards - Mr N

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You might want to download and check out the source code for
the "Error Handling in ASP.NET" Code Project article By Rakesh Rajan.

It shows how to manage several error handling configurations.

http://www.codeproject.com/aspnet/Er...lingASPNET.asp

You will need to become a member ( free ) of the Code Project
to be able to download any source code files from it, but they are
good about not hassling you or sending spam.

You can read the article without having to become a member, though.

Off hand :

1. Did you set up error handling in web.config and global.asax ?

web.config :
<customErrors mode="On" defaultRedirect="ErrDefault.aspx"/>

global.asax :
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("ErrDefault.aspx")
End Sub

2. What does "ErrDefault.aspx" do ?

I have web.config and global.asax setup that way,
and you can see the test page with your code, working OK, at :

http://asp.net.do/test/errorTest.aspx

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mr Newbie" <he**@now.com> wrote in message
news:ub*************@TK2MSFTNGP10.phx.gbl...
I'm testing error handling configurations and having some trouble. I
created a WebForm called. ErrDefault.aspx and I am trying to use the
Page error attribute to force the redirection to a custom page, but I
only get and unhandled exception page and it does not direct me to my
specific page. I'm probably doing something really stupid, but I cant see
what .

Any Ideas ? - Thanx Mr N

--------- DETAILS BELOW -----------

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="Exceptions1.WebForm1"
errorPage="ErrDefault.aspx"%>
In my button handler.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Throw New System.Net.WebException("Custom Error Page")

End Sub

Custom Error Page
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Net.WebException: Custom Error Page

Source Error:

Line 33:
Line 34: Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Line 35: Throw New System.Net.WebException("Custom Error Page")
Line 36: End Sub
Line 37: End Class


Nov 19 '05 #3

P: n/a
Yes, that was it, I forgot to set the custom error section in the
web.config, I knew it would be something really stupidly fundamental, and of
course obvious to anyone else but myself.

;-D

Cheers Mr N.
"Mr Newbie" <he**@now.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Thanks Jaun

I'll take a look tomorrow, its late right now and my brain has ceased
virtually all non automatic function.

Regards - Mr N

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You might want to download and check out the source code for
the "Error Handling in ASP.NET" Code Project article By Rakesh Rajan.

It shows how to manage several error handling configurations.

http://www.codeproject.com/aspnet/Er...lingASPNET.asp

You will need to become a member ( free ) of the Code Project
to be able to download any source code files from it, but they are
good about not hassling you or sending spam.

You can read the article without having to become a member, though.

Off hand :

1. Did you set up error handling in web.config and global.asax ?

web.config :
<customErrors mode="On" defaultRedirect="ErrDefault.aspx"/>

global.asax :
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("ErrDefault.aspx")
End Sub

2. What does "ErrDefault.aspx" do ?

I have web.config and global.asax setup that way,
and you can see the test page with your code, working OK, at :

http://asp.net.do/test/errorTest.aspx

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Mr Newbie" <he**@now.com> wrote in message
news:ub*************@TK2MSFTNGP10.phx.gbl...
I'm testing error handling configurations and having some trouble. I
created a WebForm called. ErrDefault.aspx and I am trying to use the
Page error attribute to force the redirection to a custom page, but I
only get and unhandled exception page and it does not direct me to my
specific page. I'm probably doing something really stupid, but I cant
see what .

Any Ideas ? - Thanx Mr N

--------- DETAILS BELOW -----------

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="Exceptions1.WebForm1"
errorPage="ErrDefault.aspx"%>
In my button handler.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Throw New System.Net.WebException("Custom Error Page")

End Sub

Custom Error Page
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Net.WebException: Custom Error Page

Source Error:

Line 33:
Line 34: Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Line 35: Throw New System.Net.WebException("Custom Error Page")
Line 36: End Sub
Line 37: End Class



Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.