Error Handling

A

A.M

Hi,

I have this code in my web.config:

<customErrors mode="On" defaultRedirect="~/ErrorPages/ErrorApp.aspx">
<error statusCode="400" redirect="~/ErrorPages/Error.aspx" />
<error statusCode="401" redirect="~/ErrorPages/Error.aspx" />
<error statusCode="403" redirect="~/ErrorPages/Error.aspx" />
<error statusCode="404" redirect="~/ErrorPages/Error.aspx" />
<error statusCode="408" redirect="~/ErrorPages/Error.aspx" />
<error statusCode="500" redirect="~/ErrorPages/Error.aspx" />
<error statusCode="503" redirect="~/ErrorPages/Error.aspx" />
</customErrors>

Is there any way that inside Error.aspx code I can find what was the actual
error number?

Thanks,
Al
 
S

Scott Allen

The customErrors mode results in a redirect (round trip) when an error
occurs, and since the client comes back with a new request for the
error page, the error information will be lost.

My suggestion is to implement a global error handler in the
Application_Error event handler in global.asax. From here you can
redirect or Server.Transfer to another page after you have collected
the exception information.

More details in the following article:
HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual
C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306355&ID=kb;en-us;Q306355&SD=MSDN

HTH,
 
S

Steven Cheng[MSFT]

Hi Al,

I'm viewing this thread and found that there is another duplicated one in
this queue. A community member has provided a good solution that using the
querystring param to provide the Error code info. Also I've provided some
of my suggestions there. I'd appreciate if you'd have a look. Also, if you
feel it convenient that we continue to discuss in that thread, please feel
free to follwoup there. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error Handling Question(1) 3
Frustrations with Error Logging 1
HTTP Error 404 1
CustomErrors! What is going on? 0
CustomError Problem 4
customErrors 1
<customErrors 3
CustomErrors not working on live host 1

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top