JoelFan
JoelFan

Reputation: 38714

how do I get ActionDescriptor from either ActionExecutingContext or AuthorizationContext?

I'm writing a method that just uses the ActionDescriptor property but I can't figure out how to avoid repeating the body of the method so that it can take either an ActionExecutingContext or an AuthorizationContext. Both of these types have an ActionDescriptor property, but they don't inherit it from a common type or interface that I can find.

Upvotes: 2

Views: 848

Answers (1)

Levi
Levi

Reputation: 32818

Refactor the code that consumes the ActionDescriptor into its own static method somewhere, then call that method from within your OnActionExecuting() or OnAuthorization(), passing in the ActionDescriptor object.

Upvotes: 1

Related Questions