【问题标题】:WCF stopped working on IIS 7 after adding new HTTP and HTTPS bindings添加新的 HTTP 和 HTTPS 绑定后,WCF 停止在 IIS 7 上工作
【发布时间】:2014-01-26 03:47:48
【问题描述】:

我正在使用ASP.NET 3.5 和C#。我有一个web-application 有一个WCF。我已经使用Bindings HTTP 和HTTPS 将它部署在服务器上。一切运作良好。

今天我在同一个站点上添加了两个HTTP 和HTTPS 的绑定,但with different host names。 (我已经注册了那个新域,并且我已经用我的 IP 地址指出了这一点)。突然,同一站点的WCF 停止工作。

我为IIS 中的两个站点执行此操作,并且它们都在WCF 调用上返回异常,但是login 和所有其他页面都工作正常。

web.config 的 ServiceModel 部分如下:

     <system.serviceModel>
        <bindings>
            <webHttpBinding>
                <binding name="webBindingHTTP">
                    <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
                <binding name="webBindingHTTPS">
                    <security mode="Transport">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
            </webHttpBinding>
        </bindings>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        </serviceHostingEnvironment>
        <behaviors>
            <endpointBehaviors>
                <behavior name="ihrole.service.remoteBehavior">
                    <webHttp />
                </behavior>
                <behavior name="webHttpEnabled">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="ihrole.service.remoteBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="ihrole.service.remoteBehavior" name="ihrole.service.remote">
                <endpoint address="" behaviorConfiguration="ihrole.service.remoteBehavior" bindingConfiguration="webBindingHTTP" binding="webHttpBinding" contract="ihrole.service.Iremote" />
                <endpoint address="" behaviorConfiguration="ihrole.service.remoteBehavior" bindingConfiguration="webBindingHTTPS" binding="webHttpBinding" contract="ihrole.service.Iremote" />
            </service>
        </services>
    </system.serviceModel>

同样,我确实有另一个站点托管在同一个 IIS 上,它也有 HTTP 和 HTTPS 绑定。但是我还没有在这个网站上添加新的,WCF 电话在同样的情况下工作正常。

任何猜测或解决方案? 提前谢谢..

【问题讨论】:

  • 使用 设置显示您的 Web.config
  • @FlopScientist 我已经用服务模型设置更新了这个问题。
  • 添加证书后出现完全相同的问题,原来 Skype 正在使用端口 443 并且 IIS 无法启动。只是尝试一下..

标签: asp.net wcf iis iis-7 wcf-binding


【解决方案1】:

这里您需要指定您的 WCF 服务可以在单个网站的所有 Bindings 上运行。

在 Asp.Net 3.5 中,当网站有多个绑定时,您应该使用 &lt;baseAddressPrefixFilters&gt; 元素指定通过过滤器(为 WCF 服务添加基地址)。请参阅下面的示例。 MSDN reference here.

<system.serviceModel>
    <serviceHostingEnvironment>
    ... 
        <baseAddressPrefixFilters>
            <add prefix="http://Testsite2.com:3546"/>
            <add prefix="http://testSite.com:3566"/>
        </baseAddressPrefixFilters>
   ...
    </serviceHostingEnvironment>
</system.serviceModel>

所以,这里http://Testsite2.com:3546 和http://testSite.com:3566 是它们各自方案的唯一基地址,它们将被允许通过,这意味着WCF 服务将对这两个地址起作用。 baseAddressPrefixFilter 不支持任何通配符。

【讨论】:

    猜你喜欢
    • 2010-12-21
    • 2011-04-02
    • 2016-03-24
    • 2016-03-09
    • 2011-09-05
    • 2023-03-10
    • 2015-11-22
    • 2011-03-04
    • 1970-01-01
    相关资源
    最近更新 更多