如何在Controller中的OnActionExecuting中检查应用哪些ActionFilterAttribute?
答案 0 :(得分: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);