如何向Windows服务中托管的WCF服务添加基本身份验证?
我在绑定中添加了一个安全标记,但是当我在浏览器中调用服务URL时,我没有获得身份验证窗口。我做错了什么/我错过了什么?
<bindings>
<basicHttpBinding>
<binding name="MyDefaultBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000">
<readerQuotas maxDepth="500" maxArrayLength="20000000" maxStringContentLength="20000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
答案 0 :(得分:4)
只访问服务帮助程序页面时,您将无法获得该身份验证窗口。为服务端点配置了身份验证 - 而不是帮助页面或WSDL(那些是“单独的端点”)。
尝试修改配置:
<bindings>
<customBinding>
<binding name="securedPages">
<textMessageEncoding messageVersion="None" />
<httpsTransport authenticationScheme="Basic" />
</binding>
<customBinding>
<basicHttpBinding>
<binding name="MyDefaultBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000">
<readerQuotas maxDepth="500" maxArrayLength="20000000" maxStringContentLength="20000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="securedService">
<serviceMetadata httpGetEnabled="true" httpGetBinding="customBinding"
httpGetBindingConfiguration="securedPages" />
<serviceDebug httpHelpPageEnabled="true" httpHelpPageBinding="customBinding"
httpHelpPageBindingConfiguration="securedPages" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="..." behaviorConfiguration="securedService">
...
</service>
</services>