Error Handling

  • Thread starter Thread starter A.M
  • Start date Start date
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
 
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,
 
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
 
Back
Top