阻止对Elmah操作应用ASP.NET MVC全局过滤器 [英] Prevent a ASP.NET MVC global filter from being applied on Elmah action

查看:75
本文介绍了阻止对Elmah操作应用ASP.NET MVC全局过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Elmah使用 Alex Beletsky的elmah-mvc在我的MVC应用程序中记录异常> NuGet程序包.

I'm using Elmah for logging exceptions on my MVC application using Alex Beletsky's elmah-mvc NuGet package.

应用程序注册了一些全局过滤器,这些全局过滤器应用于每个调用的动作.

The application registers some global filters, applied on each action called.

是否有一种方法可以防止在调用Elmah.Mvc.ElmahController错误日志页面(foo.com/elmah)时应用某些过滤器?

Is there a way to prevent some of those filters from being applied when calling the Elmah.Mvc.ElmahController error log page (foo.com/elmah) ?

以下测试当然可以,但是我正在寻找一种更优雅的方式,该方式不涉及修改过滤器(也不包括Elmah/Elmah MVC的源代码).甚至有可能吗?

A test like below works, of course, but I'm looking for a more elegant way that would not involve modifying the filter (nor the source code from Elmah / Elmah MVC). Is it even possible ?

public class FooAttribute : FilterAttribute, IActionFilter
{
    // ...

    public void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if (filterContext.Controller is ElmahController)
        {
            return;
        }

        // do stuff
    }
}

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆