问题
Does HealthMonitoring have a built-in event that catches 404 errors? I have tried setting up all events (by using webBaseEvent) and I've searched for two days, but I cannot find or trigger an event for a file not found.
I could create my own, but was hoping there was a built in event.
回答1:
No, it doesn't. You'd have to create a custom event (from webrequesterrorevent) to have HM track it for you.
How to: Something like this (from memory) in Application_Error in global.asax -
public void Application_Error()
{
var exception = Server.GetLastError() as HttpException;
if (exception != null && exception.GetHttpCode() == 404)
{
//custom error
new Http404Event(this, exception).Raise();
}
}
来源:https://stackoverflow.com/questions/4957566/asp-net-health-monitoring-404-event