I am new to the built in health monitoring functionality that comes built into the .net framework. I have followed a v.good video tutorial and I cant seem to get the last part of my code to work correctly...
I have configured my app to display an error page (when necessary) and this will write errors to the event viewer along with my custom error messages - this works fine.
My problem is when I try to write these same errors to sql. Here is my code from web config:-
Expand|Select|Wrap|Line Numbers
- <healthMonitoring>
- <eventMappings>
- <add name="InputValidationEvent"
- type="WebEvents.InputValidationEvent, WebEvents"/>
- </eventMappings>
- <rules>
- <add name="InputValidationToSql"
- eventName="InputValidationEvent"
- provider="SqlWebEventProvider"
- profile="Critical"/>
- </rules>
- </healthMonitoring>
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Web.Management;
- namespace WebEvents
- {
- public class InputValidationEvent : WebFailureAuditEvent
- {
- public InputValidationEvent(object sender, string message)
- : base(message, sender, WebEventCodes.WebExtendedBase + 1)
- {}
- public override void FormatCustomEventDetails(WebEventFormatter formatter)
- {
- base.FormatCustomEventDetails(formatter);
- //formatter.AppendLine("This is where you can write custom message for the event logger!");
- formatter.AppendLine(string.Format("Actual error exception raised by the PNWeb app : {0}",this.Message));
- }
- }
- }
1) Errors are written to the event viewer - which is ok.
2) In App-Data (within my app) an ASPNETDB.MDF file appears, along with aspnetdb_log.LDF.
It doesn't write the error to the aspnet_webevents_events table which exists in my DB?
So what I need to know is: Why does it write the error to the DB within the App_data folder & NOT to the aspnet_webevent_events table in my database?
Hope I've explained in enough detail - its driving me nuts!
Thanks
Janet