2

Is it possible to use ExceptionFilterAttribute in a project the was created with MVC2 and upgraded to MVC4? It is not a Web API project, and I cannot seem to get the exception to catch using the ExceptionFilterAttribute. Is there any way to make this happen or am I better off just sticking to inheriting from ActionFilterAttribute and implementing IExceptionFilter. This is for an API section within our MVC project

4

1 回答 1

3

MVC 属性和 Web API 属性不兼容。

MVC 属于System.Web.Mvc.Filter[1] 类型,而 Web API 属于System.Web.Http.Filters.Filter[2] 类型 - 因此在尝试将属性应用于 Web API 之前,您需要确保您的基类正确无误。

[1] - http://msdn.microsoft.com/en-us/library/system.web.mvc.filter(v=vs.98).aspx

[2] - http://msdn.microsoft.com/en-us/library/system.web.http.filters.filter(v=vs.108).aspx

于 2012-11-09T01:43:24.510 回答