NET运行状况监视事件404

NET运行状况监视事件404

本文介绍了ASP.NET运行状况监视事件404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否HealthMonitoring有一个内置的事件,捕获404错误?我试图建立的所有事件(通过使用webBaseEvent)和我搜索了两天,但我无法找到或触发事件未找到的文件。

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.

推荐答案

没有,没有。你必须创建一个自定义事件(从webrequesterrorevent)有HM跟踪它。

No, it doesn't. You'd have to create a custom event (from webrequesterrorevent) to have HM track it for you.

如何:
像这样的事情(从内存)中的Application_Error Global.asax中 -

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();
    }
}

这篇关于ASP.NET运行状况监视事件404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:42