【问题标题】:WCF Exception: Security settings for this service require 'Anonymous' AuthenticationWCF 异常:此服务的安全设置需要“匿名”身份验证
【发布时间】:2019-11-21 07:02:30
【问题描述】:

我正在 VisualStudio 2010 中创建一个简单的 WCF 服务。我正在使用 basicHttpBinding 方法。

当我在浏览器中查看 .svc 时,我收到以下错误:

'此服务的安全设置需要 Windows 身份验证,但托管此服务的 IIS 应用程序未启用它。'

我的 web.config 看起来像,

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>



    <services>
      <service behaviorConfiguration="IAManagement.Service1Behavior"
        name="IAManagement.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="IAManagement.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="IAManagement.CreateIABehavior"
        name="IAManagement.CreateIA">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding"
          name="BasicHttpEndpoint" contract="IAManagement.ICreateIA">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="IAManagement.Service1Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="IAManagement.CreateIABehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

谁能帮我解决这个问题?谢谢

【问题讨论】:

    标签: wcf


    【解决方案1】:

    您的配置如下:

    <binding name="BasicHttpEndpointBinding"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /> </security> </binding> 
    

    是使用 Windows 身份验证来验证客户端,并且尚未在 IIS 上配置相同的设置。

    如果您希望客户端身份验证类型为 Windows,则进入 IIS 并选择虚拟目录,您可以找到一个名为“身份验证”的部分。双击,您可以找到“Windows 身份验证”作为元素之一,其状态应为“启用”以使您的 Web 服务正常工作。

    如果您不想要任何类型的身份验证,则需要将安全模式设置为无,这将在浏览器中显示您的服务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多