【问题标题】:Enable HTTPS traffic for WCF Service. Issue with changing traffic http to https为 WCF 服务启用 HTTPS 流量。将流量 http 更改为 https 的问题
【发布时间】:2019-02-08 10:43:40
【问题描述】:

问题是: 我尝试将 WCF 服务流量从 HTTP 更改为 HTTPS。但我无法访问此服务,我收到 404 错误。我看到一些博客说我们需要添加自定义绑定。但我没有。

请帮帮我。 下面是我的默认 HTTP 绑定的 Web 配置。

我希望将其更改为 HTTPS。

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp helpEnabled="True" />
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <protocolMapping>
      <add binding="webHttpBinding" scheme="http" />

    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
    <httpProtocol>
    </httpProtocol>
  </system.webServer>

【问题讨论】:

  • 只是一个问题,但是您是否在 IIS 中托管此服务?
  • 是在 Azure 中托管。
  • 不确定,但我认为您可以配置 azure 以在 443 SSL 端口上托管服务。不过你需要一个证书。
  • 在没有证书的情况下,我可以将 Web 应用程序 UI 部分的 http 流量更改为 https。仅在 WCF 的情况下,我无法做到。对于 WCF,我们必须需要 SSL 证书吗?
  • 我的印象是任何其他 Web 应用程序也需要 SSL/TSL 证书(如果您使用的是 https)。

标签: c# asp.net .net wcf web-config


【解决方案1】:

我在&lt;behaviors&gt; 标签下面添加了以下代码,并且工作起来就像一个冠军。

<bindings>
        <webHttpBinding>
            <binding>
                <security mode="Transport" />
                </binding>
        </webHttpBinding>
    </bindings>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-27
    • 2023-02-01
    • 1970-01-01
    • 2017-08-13
    • 2015-01-03
    • 2015-02-06
    • 2021-04-14
    • 2014-04-20
    相关资源
    最近更新 更多