469,945 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Best strategy for all errors?

Many of our apps are in production and they do not have proper error logging
in them - unhandled errors are seen by the users in the form of error
messages and stack traces. I know how to make apps handle their errors
(global.asax.cs "application_error" event, web.config "customErrors"
section, etc). But can I do this without having to visit each app? Can
this be done at the machine level? I'm looking for a kind of machine-level
"application error" event that will handle any untrapped errors. How is
this done? Thanks! --Marty
Nov 18 '05 #1
2 1418
Hi Marty,
Thanks for posting in the community!
From your description, you'd like to provide a more friendly error
displaying view(a custom error screen) for the client user rather then the
system's exception detailed info page when unhandled exceptions occurs in
ASP.NET web applicatoin. Also, you want to find some place to configure it
at machine level rather than configure it everytime in a certain web
application, yes?
If there is anything I misunderstood, please feel free to let me know.

Based on my experience, you can try using the <customErrors > element in
the ASP.NET 's web application configuration schema. There is a "mode"
attribute in the <customErrors> element, we can set it to control whether
to show the detailed error info page or redirect user to the custom error
page (set via the "defaultRedirect" attribute). For example:

<customErrors defaultRedirect="mycustomererrorpage.htm" mode="On">
</customErrors>

The above setting told the ASP.NET runtime when unhandled error occurs,
don't show the detailed exception info page( because we set the "mode=On"),
and redirect the user to the custom error page(we set in the
"defaultRedirect" attribute).
Here is the detailed description of the "mode" attribute in MSDN:

On-------------------- Specifies that custom errors are enabled. If no
defaultRedirect is specified, users see a generic error.

Off -------------------Specifies that custom errors are disabled. This
allows display of detailed errors.

RemoteOnly -------------------Specifies that custom errors are shown only
to remote clients and ASP.NET errors are shown to the local host. This is
the default.

For detailed info of the <customErrors> configure tag, you can view the
following tech reference in MSDN:
#<customErrors> Element
http://msdn.microsoft.com/library/en...tomerrorsSecti
on.asp?frame=true

This error handling setting can be configured in both web.config file(web
application level) and machine.config(machine level). Since you want to set
it for all web apps on a certain machine, you can find the <customErrors>
tag in the machine.config file and set it. For example, if you want to
prevent client user from seeing the detailed exception info page. You can
set the <customErrors> tag in machine.config as below:
<customErrors defaultRedirect="customErrorPage.html" mode="RemoteOnly">
</customErrors>

Then, you also need to have a "customErrorPage.html in each web
application. After that, each time unhandled exception occurs in a web
application, the remote user will see the customErrorPage.html rather than
the detailed exception info page. But the localuser can still see the
detailed error info page. How do you think of this?

In addition, here is some other tech aritcles on ASP.NET configuration and
providing custom error report page:

#INFO: ASP.NET Configuration Overview
http://support.microsoft.com/?id=307626

#HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C#
.NET
http://support.microsoft.com/?id=306355

#Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/en...rs.asp?frame=t
rue

I believe they're also helpful to you. Please check out the above
suggestions. If you feel anything unclear, please feel free to post here.

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.)

Nov 18 '05 #2
Hi Marty,
Have you had a chance to try out my suggestions or have you got any ideas
on this issue? If you need any assistance, please feel free to post here.


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.)

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Binoy | last post: by
4 posts views Thread by Claudio Jolowicz | last post: by
10 posts views Thread by Neil | last post: by
136 posts views Thread by Matt Kruse | last post: by
reply views Thread by cyprian.pl | last post: by
4 posts views Thread by Paciente8159 AKA Klayman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.