Consider the following code:
public class MyAttribute : Attribute { } [MyAttribute] public class MyControlller : Controller { //... }
Now that I have a Global Action Filter that gets me an ActionExecutingContext object.
Global Action Filter
ActionExecutingContext
My question is how can I check if the requested Controller decorated with my custom Attribute .
Controller
Attribute
Try
actionExecutingContextInstance.Controller.GetType().GetCustomAttributes(typeof(MyAttribute), false).Length > 0)
Or
actionExecutingContextInstance.ActionDescriptor.GetCustomAttributes(typeof(MyAttribute), false).Length > 0)