我更改了Web.Config,该服务正在使用匿名身份验证 . 虽然在IIS7.5中启用了Windows身份验证并禁用了匿名身份验证,但它会开始给我以下错误 . 请帮忙 .
主机上配置的身份验证方案('IntegratedWindowsAuthentication')不允许在绑定'basicHTTP'('Anonymous')上配置的身份验证方案 . 请确保将SecurityMode设置为Transport或TransportCredentialOnly . 此外,可以通过IIS管理工具,通过ServiceHost.Authentication.AuthenticationSchemes属性,在元素的应用程序配置文件中更改此应用程序的身份验证方案,通过更新绑定上的ClientCredentialType属性,或通过调整HttpTransportBindingElement上的AuthenticationScheme属性 .
Web.config如下:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="JSONBinding"></binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHTTP">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JSON">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="RestWCFService.CalculationService" behaviorConfiguration="basicBehavior">
<endpoint address="" binding="basicHttpBinding" contract="RestWCFService.ICalculatorService" bindingName ="basicHTTP"></endpoint>
<!--
<endpoint behaviorConfiguration="JSON" binding="webHttpBinding" bindingConfiguration="JSONBinding" contract="RestWCFService.ICalculatorService" name="JSONService"></endpoint>
-->
</service>
</services>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http"/>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
提前致谢!!!
1 回答
您没有在 endpoints 中使用名为
basicHTTP
的基本HTTP绑定 . 将 endpoints 中的属性从bindingName="basicHTTP"
更改为bindingConfiguration="basicHTTP"
.顺便说一下,您必须在IIS中启用匿名身份验证和Windows身份验证 .