asp.net-mvc

How-to figure out if an action method has a HttpPost attributte?


How-to figure out if an action method has a HttpPost attributte ?

For example in the action filter..


Solution

  • You can use ActionDescriptor.GetCustomAttributes to get attributes applied to the action. Both ActionExecutingContext and ActionExecutedContext expose a property called ActionDescriptor allowing you to get an instance of ActionDescriptor class.