我已启用Windows身份验证as described here
一切正常,只是一个小问题:这样做会使每个控制器方法都受到Windows身份验证的保护。没问题我想,只需在匿名访问可以使用的少数控制器方法上使用[AllowAnonymous]装饰器,但这不会起作用。
有没有办法让自主机没有授权每个控制器上的每个方法?
答案 0 :(得分:2)
您必须启用Windows身份验证和匿名身份验证。 documentation。你也告诉Owin需要Windows身份验证并禁止其他任何操作。
在你引用的代码中,你会改变这个:
listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication
| AuthenticationSchemes.Anonymous;