ASP.NET MVC5自定义全局错误处理程序
如何在AutoFac IoC容器中注册自定义全局异常属性?
public class ExceptionLoggingFilter : FilterAttribute, IExceptionFilter
{
private IRepo _repo;
public ExceptionLoggingFilter(IRepo repo)
{
this._repo = repo;
}
}发布于 2016-11-01 23:09:57
遵循为其他操作筛选器类型as noted in the documentation概述的模式。所有筛选器类型都有扩展方法。
builder.RegisterFilterProvider();
builder.RegisterType<ExceptionLoggingFilter>()
.AsExceptionFilterFor<MyController>();或者,使用带有属性注入的属性,只注册过滤器提供程序。
https://stackoverflow.com/questions/40337331
复制相似问题