如何检查从控制器的 OnActionExecuting 中应用了哪些 ActionFilterAttributes?
问问题
123 次
1 回答
1
也许它可以帮助你:
[HttpGet]
public ActionResult Index()
{
var attributes = Attribute.GetCustomAttributes(typeof(HomeController).GetMember("Index").First());
return View();
}
结果应该是这样的:
更新
var onlyActionFilterAttributesForClass =
typeof(HomeController).GetCustomAttributes(true).Where(
x => x as ActionFilterAttribute != null);
var onlyActionFilterAttributesForMember = Attribute.GetCustomAttributes(typeof (HomeController).GetMember("Index").First()).
Where(
x => x as ActionFilterAttribute != null);
于 2012-11-26T05:57:59.113 回答