繁体   English   中英

在mvc4 HandleErrorAttribute扩展类中定义一个具有[HttpPost]的ActionMethod

[英]Define an ActionMethod has [HttpPost] in mvc4 HandleErrorAttribute extension class

我想知道一个动作方法是否具有[HttpPost]。 我的代码如下。 但是它总是返回null。

string actionName = filterContext.RouteData.Values["action"].ToString();
Type controller = filterContext.Controller.GetType();
MethodInfo method = controller.GetMethod(actionName); //OK Code
var attribute = method.GetCustomAttribute(typeof(HttpPostAttribute), true); //returns null

有什么建议吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM