Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpGet]
- public void MyResource()
- {
- // Controller logic
- }
- public void GetControllerMethodHttpAttribute()
- {
- MethodInfo controllerMethod = typeof(TestController).GetMethods().First();
- // Solution 1
- var attrs = controllerMethod.Attributes;
- // Solution 2
- var httpAttr = Attribute.GetCustomAttributes(typeof(HttpGetAttribute));
- // Solution 3
- var httpAttr2 = Attribute.GetCustomAttribute(controllerMethod, typeof(HttpGetAttribute));
- // Solution 4
- var httpAttr3 = Attribute.IsDefined(controllerMethod, typeof(HttpGetAttribute));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement