我有這樣爲什麼不捕獲[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