Custom Error Handling Problem /Question

  • Thread starter Thread starter Mr Newbie
  • Start date Start date
M

Mr Newbie

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
 
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/ErrorHandlingASPNET.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/
======================================
 
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
 
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.
 
Back
Top