【问题标题】:Silverlight 3 + WCF and IIS basic authenticationSilverlight 3 + WCF 和 IIS 基本身份验证
【发布时间】:2010-12-02 11:55:58
【问题描述】:

我有以下问题。在我的机器上,我有一个 SL 3 应用程序,它基本上包括:

* Client app (SL)
* Web app (.Net 3.5)
* Communication with the database handled by WCF

该站点托管在我的 IIS 上,并设置了以下身份验证:

* Anonymous access: off
* Basic authentication: on
* Integrated Windows authentication: on

我的绑定设置如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                    <security mode="TransportCredentialOnly" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost/MyApp/WCFPortal.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal"
                name="BasicHttpBinding_IWcfPortal" />
        </client>
    </system.serviceModel>
</configuration>

Web.config:

  <authentication mode="Windows" />
  <identity impersonate="true" />

当我导航到我的网站时,系统会提示我输入用户名和密码。正确填写后,我可以访问该站点,但数据库通信不起作用。当我转到 localhost/MyApp/WcfPortal.svc 时,我收到以下错误:

此服务的安全设置需要“匿名”身份验证,但托管此服务的 IIS 应用程序未启用。

我尝试将&lt;transport clientCredentialType="Windows" /&gt; 添加到 basicHttpBinding 的安全性中,但 VS 给了我警告“未声明 'clientCredentialType' 属性。”。

如果有人能帮我解决这个问题,我将不胜感激。

【问题讨论】:

    标签: wcf iis silverlight-3.0


    【解决方案1】:

    我解决了我的问题。原来我必须在两个地方更改 basicHttpBinding:ServiceReferences.ClientConfig 和 Web.Config

    ServiceReferences.ClientConfig:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
              <security mode="TransportCredentialOnly" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost/MyApp/WCFPortal.svc" binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal"
              name="BasicHttpBinding_IWcfPortal" />
        </client>
      </system.serviceModel>
    </configuration>
    

    Web.config:

    ...

        <authentication mode="Windows" />
    ...
    
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="10000000" maxReceivedMessageSize="10000000" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Ntlm" />
                </security>
                <readerQuotas maxBytesPerRead="10000000" maxArrayLength="10000000" maxStringContentLength="10000000"/>
            </binding>
          </basicHttpBinding>
        </bindings> 
    

    【讨论】:

      【解决方案2】:

      很遗憾,要在 IIS6 下托管此服务,您必须打开匿名身份验证。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-10-11
        • 2012-01-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-02
        相关资源
        最近更新 更多