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 interfac开发者_StackOverflowe that I can find.
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.
精彩评论