Asp. How to use HealthMonitor properties in net

Source: Internet
Author: User
in ASP. NET 2.0, you can use the healthmonitoring property to monitor events. The Healthmonitoring property is a method-based provider, where you can construct your own provider. With the Healthmonitoring property, we can create our own providers for different data sources, such as event logs, SQL Server, or even for ourselves by inheriting the Webeventprovider class, such as documenting the wrong language, succeeding events, and so on. In this article, I'm going to introduce a Web application that configures a server to monitor the wrong language and send mail to someone's e-mail address. First, take a look at the healthmonitoring program fragment in Web. config, where you can create the event you want to use.


If you look at the

Buffermodes, where you can define a provider buffer size.

Providers, where the Providers to handle the event is described.

Eventmappings, where you can draw an event name related to the type of friendly event.

profiles, where you define a collection of parameter sets that you can use to configure events.

Rules, draw the providers event diagram here.

You can read more about these elements in the VS 2550 document.

Before proceeding, here is a list of some of the providers that are included in asp:

System.Web.Management.MailWebEventProviderSystem.Web.Management.SimpleMailWebEventProviderSystem.Web.Management.Templated Mailwebeventprovidersystem.web.management.tracewebeventprovidersystem.web.management.eventlogwebeventprovidersystem.web.m Anagement. SqlWebEventProviderSystem.Web.Management.WmiWebEventProvider

No need to explain these, names tell us what they are. Also mention that SqlWebEventProvider relies on SQL Server to work, and it stores events in the Aspnet_web_event table. In order to install this database, you must run the Aspnet_regsql.exe Wizard located in the Framework folder.

Now, configure the program that has a logon error for SQL Server provider and sends an e-mail message that produces an incorrect result.

Here is an example of using SqlWebEventProvider and Simplemailwebeventprovider to store the wrong language event.

In this example, SQL provider is used to log all the wrong-language events and a message is sent using mail provider when the Web request Error event is awakened.

Here are some events published by ASP. NET 2.0:

System.Web.Management.WebBaseEventSystem.Web.Management.WebHeartBeatEventSystem.Web.Management.WebApplicationLifetimeEven TSystem.Web.Management.WebRequestEventSystem.Web.Management.WebBaseErrorEventSystem.Web.Management.WebErrorEventSystem.We B. Management.WebRequestErrorEventSystem.Web.Management.WebAuditEventSystem.Web.Management.WebFailureAuditEventSystem.Web.Ma Nagement. WebSuccessAuditEventSystem.Web.Management.WebManagementEventSystem.Web.Management.WebViewStateFailureAuditEventSystem.Web . Management.WebAuthenticationFailureAuditEventSystem.Web.Management.WebAuthenticationSuccessAuditEvent

You can use these events to paint a provider. You can also create your own events that are inherited through the WebBaseEvent class.

To wake an event automatically, you can use the wake-up method of the WebBaseEvent class:

try{//....}
catch (Exception e) {if (healthmonitoringmanager.enabled) {webbaseevent.raise ( New Weberrorevent ("My Error message", NULL, +, E)); }}or:if (healthmonitoringmanager.enabled) {weberrorevent event = new Weberrorevent ("My error message", NULL, e); eve Nt. Raise ();} 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.