【问题标题】:Accessing parameters of custom action filter attributes into IsAuthorized将自定义操作过滤器属性的参数访问到 IsAuthorized
【发布时间】:2017-12-27 17:50:32
【问题描述】:

我已经为 Web api 2 创建了自定义属性。我继承自 Authorize 属性。新属性采用 params 属性,例如 public MyAuthorizeAttribute(params string[] scopes){}

和用法将是这样的 MyAuthorizeAttribute("Test1","Test2")。 我如何访问 Test1 和 Test2 到 protected override bool IsAuthorized(HttpActionContext actionContext){}

谢谢

【问题讨论】:

    标签: filter authorize-attribute actionfilterattribute webapi2


    【解决方案1】:

    未进行 BaseClass 构造函数调用。所以默认构造函数被调用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 2013-09-16
      相关资源
      最近更新 更多