我有这样为什么不捕获[HttpGet]和[HttpPost]属性?
foreach(var controller in controllers)
{
// ...
var actions = controller.GetMethods()
.Where(method => method.ReturnType == typeof(IHttpActionResult));
foreach(var action in actions)
{
// ...
var httpMethodAttribute = action.GetCustomAttributes(typeof(System.Web.Mvc.ActionMethodSelectorAttribute), true).FirstOrDefault() as System.Web.Mvc.ActionMethodSelectorAttribute;
// ...
}
}
一段代码,但由于某种原因httpMethodAttribute
总是null
即使我可以证实,action
有CustomAttribute
是is
一个System.Web.Mvc.ActionMethodSelectorAttribute
。任何想法我做错了什么?
如果我的回答很满意,你会介意接受它?如果没有,让我知道,我会扩大它。 – Amy