【问题标题】:The authentication schemes configured on the host ('Anonymous') do not allow those configured on the binding 'WebHttpBinding' ('Basic')在主机('Anonymous')上配置的身份验证方案不允许在绑定'WebHttpBinding'('Basic')上配置的那些
【发布时间】:2014-10-26 21:15:15
【问题描述】:

我按照这里的教程:http://allen-conway-dotnet.blogspot.co.uk/2012/07/using-basic-authentication-in-rest.html?_sm_au_=iFVksVM0H8QrkntP,在 WCF 服务中实现用户身份验证,但我收到以下错误:

主机上配置的身份验证方案(“匿名”)不允许那些配置的 在绑定'WebHttpBinding'('Basic')上。请确保将 SecurityMode 设置为 Transport 或 TransportCredentialOnly。此外,这可以通过更改 此应用程序的身份验证方案通过 IIS 管理工具,通过 ServiceHost.Authentication.AuthenticationSchemes 属性,在应用程序配置中 通过更新绑定上的 ClientCredentialType 属性或通过 调整 HttpTransportBindingElement 上的 AuthenticationScheme 属性。

我确实尝试在项目中禁用“匿名身份验证”,但我得到的只是错误 401 - 未经授权。没有出现输入用户名和密码的提示。有谁知道为什么会出现这个问题以及如何解决它?

【问题讨论】:

    标签: c# wcf authentication webhttpbinding


    【解决方案1】:

    我终于设法通过添加以下内容解决了这个问题:

    <behavior name="...">
         ...
         <serviceAuthenticationManager authenticationSchemes="Basic"/>
         ...
    </behavior>
    

    【讨论】:

    • 这让我更接近了,但我仍然遇到身份验证错误(另一个)。我最终直接从 IIS Express 配置文件启用了基本身份验证。只需按照此解决方案中的步骤操作:stackoverflow.com/a/19032453/151325
    • @Dawid O 你在哪里添加的?我也面临同样的问题
    猜你喜欢
    • 1970-01-01
    • 2016-02-21
    • 2013-12-09
    • 2015-06-21
    • 2016-02-03
    • 2013-07-29
    • 1970-01-01
    • 2014-11-16
    • 1970-01-01
    相关资源
    最近更新 更多