【问题标题】:Receiving 404 when configuring WCF with HTTPS使用 HTTPS 配置 WCF 时收到 404
【发布时间】:2019-11-12 21:05:42
【问题描述】:

我部署了一个 .NET 4.5 站点,其中包含一个 MVC 部分和一个 WCF 部分。 WCF 托管在 IIS 内,它是 MVC 应用程序的子应用程序/子站点。

我遇到的问题是,当 MVC 调用 WCF 时,我无法让 HTTPS 工作。 HTTP 可以工作,但是一旦我添加 HTTPS 配置,它就会停止工作。

这是我的配置: MVC:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IApplicationContract" >
                <security mode="Transport">  
                    <transport clientCredentialType="None"/>  
                </security>             
             </binding>
        </basicHttpBinding>        
    </bindings>
    <client>
        <endpoint address="https://mysiteaddress.com/wcf/MyService.svc/Application" 
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApplicationContract" 
            contract="MyServiceReference.IApplicationContract" name="BasicHttpBinding_IApplicationContract" />
    </client>
</system.serviceModel>

WCF:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpStreaming" maxReceivedMessageSize="67108864" transferMode="Streamed">         
            <security mode="Transport">  
                <transport clientCredentialType="None"/>  
            </security>             
        </binding>
      </basicHttpBinding>     
    </bindings>
    <services>
        <endpoint address="Application" binding="basicHttpBinding" contract="MyService.Contract.IApplicationContract" />
      </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServicebehavior">
                <serviceDebug includeExceptionDetailInFaults="True" />
                <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

我收到一条错误消息:

“EndpointNotFoundException:在https://mysiteaddress.com/wcf/MyService.svc/Application 处没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。]”

如果在 MVC 配置中,我将端点地址更改为“http://localhost/wcf/MyService.svc/Application”并删除元素,然后在 WCF 中删除 ,换句话说,删除所有 HTTPS 设置,一切正常!

在使用 HTTPS 设置之前,我遇到了一个安全错误配置错误,在我添加代码以启用 TLS 1.2 后该错误消失了,因为它在 .NET 4.5 上默认未启用。

有人知道我在这里缺少什么吗? IIS 有一个绑定,MVC 站点在 HTTPs 中运行良好,只是当它尝试调用 WCF 时,会发生错误。

【问题讨论】:

    标签: .net asp.net-mvc wcf https


    【解决方案1】:

    显然,对于 WCF 配置,在 HTTP 中,如果您确实在 basicHttpBinding 元素中指定了多个绑定,并在服务部分中省略了 services/service/endpoint/@bindingConfiguration 属性,它将正常工作。但是,在 HTTPS 中,这会给您一个 404。因此请记住始终将 bindingConfiguration 属性添加到端点。

    【讨论】:

      猜你喜欢
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-14
      相关资源
      最近更新 更多