一开始出现问题,在网上找各种资料,后来看到了这篇文章,http://blog.csdn.net/song_jiang_long/article/details/52605660,按照文章里讲的,这么去做,就会提示找不到IsDefined,后来去看官方的代码,终于解决了,附上解决方案

在重写的OnAuthorization里加上如下代码,

            bool flag = ((ReflectedHttpActionDescriptor)actionContext.ActionDescriptor).MethodInfo.IsDefined(typeof(AllowAnonymousAttribute), true) ||
                actionContext.ActionDescriptor.ControllerDescriptor.ControllerType.IsDefined(typeof(AllowAnonymousAttribute), true);
            if (flag)
            {
                return;
            }

AllowAnonymous属性就可以用了

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-06-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-01-31
相关资源
相似解决方案