44.5. Health Monitoring

ASP.NET includes a built-in framework for generating and capturing events for the purposes of monitoring a web application. This feature, called Health Monitoring, allows you to become more proactive in managing your production web applications, enabling you to be notified as soon as a problem occurs.

The Health Monitoring feature does much more than just alerting you that an exception has occurred. You can also instrument your code and generate alerts for custom events (for example, if a user fails to log on or attempts to access a restricted area.)

Health Monitoring is enabled through the web.config file. Within the system.web node you need to include a healthMonitoring node that contains the attribute enabled with a value of true. This node will also contain the details of which provider to use and rules for handling different events. Extending the web.config file from earlier, we have created an SMTP provider and a rule that e-mails the details of any unhandled exceptions to the webmaster. The web.config file has also been modified to include a reference to an SMTP server, so that the provider can send the e-mail notifications.

<configuration> <appSettings/> <connectionStrings/> <system.web> <compilation debug="true" strict="false" explicit="true" /> <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="AccessDenied.html" /> <error statusCode="404" redirect="PageNotFound.html" /> </customErrors> <trace ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.