通过禁用匿名身份验证

时间:2019-06-17 13:10:35

标签: c# rest wcf iis-7.5

  

主机上配置的身份验证方案   ('IntegratedWindowsAuthentication')不允许在   绑定“ BasicHttpBinding”(“匿名”)。请确保   SecurityMode设置为Transport或TransportCredentialOnly。   此外,这可以通过更改身份验证来解决   通过IIS管理工具为此应用程序的方案   ServiceHost.Authentication.AuthenticationSchemes属性中的   应用程序配置文件位于   元素,通过更新绑定上的ClientCredentialType属性,   或通过调整页面上的AuthenticationScheme属性   HttpTransportBindingElement。

我们在IIS 7.5上托管了WCF Rest服务 如果在IIS中启用了“匿名身份验证”,我们就可以浏览该服务。

但是,如果禁用了IIS上的匿名身份验证,则会遇到上述错误消息。

我们正在使用webHttpBinding并具有以下定义的绑定

<binding name="ExternalServicesRestBinding" closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
          </security>
        </binding>

具有端点行为

 <behavior name="endpointBehaviourForRestService">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <webHttp />
        </behavior>

请提供任何建议或线索,您认为可以解决该问题?

谢谢。

Rajkumar。

1 个答案:

答案 0 :(得分:0)

我的申请中遇到了类似的问题。

我对该服务的服务行为配置名称有疑问。我有正确的如下。这解决了我的问题。

示例:

<system.serviceModel>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="service_namespace.service_Class" >

,还有一点是,当您实现REST服务时,我们需要将Factory="System.ServiceModel.Activation.WebServiceHostFactory"添加到.svc文件中。 (您会收到“找不到端点”错误,但是无论如何正确调用该服务,它都可以正常工作。如前所述,我在.NET 4.6(简化的WCF配置)中使用了默认的Web.config。需要添加端点详细信息才能再次使用。

请检查您的配置设置和svc文件。