As you below can see, in my ActionFilter, I try to get the ActionName and the MethodInfo of the ActionExecutingContext.ActionDescriptor. But the compiler says that ActionDescriptor doesn't contain a definition for ActionName and MethodInfo. But if I debug the application, I can see, that the ActionDescriptor contains these properties (see pics below). I'm using ASP .NET Core and I have no idea, where the problem could be.
You need to cast it to ControllerActionDescriptor since that class has the properties you need.
var descriptor = context.ActionDescriptor as ControllerActionDescriptor;
var actionName = descriptor.ActionName;
var methodInfo = descriptor.MethodInfo;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With