WCF服务需要仅为HTTPS,但只能在HTTP上工作

WCF服务需要仅为HTTPS,但只能在HTTP上工作,wcf,https,web-config,Wcf,Https,Web Config,我有一些WCF服务已经在HTTP上工作了一段时间 我现在将它们移动到部署服务器,它们只需要是HTTPS 我得到了证书,当我最初设置证书时,它们通过HTTP和HTTPS工作 …此时,我想放弃对服务的非安全访问 因此,我试图对我的web.config进行修改以实现这一点: 服务行为: <serviceBehaviors> <behavior name="MetaEnabledBahavior"> <serviceMetadata httpsGet

我有一些WCF服务已经在HTTP上工作了一段时间

我现在将它们移动到部署服务器,它们只需要是HTTPS

我得到了证书,当我最初设置证书时,它们通过HTTP和HTTPS工作

…此时,我想放弃对服务的非安全访问

因此,我试图对我的web.config进行修改以实现这一点:

服务行为:

  <serviceBehaviors>
    <behavior name="MetaEnabledBahavior">
      <serviceMetadata httpsGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
  <service name="Services.BookingService" behaviorConfiguration="MetaEnabledBahavior">
    <!-- Service Endpoints -->
    <clear/>
    <endpoint address="https://website.com/services/BookingService.svc" binding="wsHttpBinding"
       bindingConfiguration="TransportSecurity" contract="Services.IBookingService"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity" maxReceivedMessageSize="2000000">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

服务端点:

  <serviceBehaviors>
    <behavior name="MetaEnabledBahavior">
      <serviceMetadata httpsGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
  <service name="Services.BookingService" behaviorConfiguration="MetaEnabledBahavior">
    <!-- Service Endpoints -->
    <clear/>
    <endpoint address="https://website.com/services/BookingService.svc" binding="wsHttpBinding"
       bindingConfiguration="TransportSecurity" contract="Services.IBookingService"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity" maxReceivedMessageSize="2000000">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

绑定:

  <serviceBehaviors>
    <behavior name="MetaEnabledBahavior">
      <serviceMetadata httpsGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
  <service name="Services.BookingService" behaviorConfiguration="MetaEnabledBahavior">
    <!-- Service Endpoints -->
    <clear/>
    <endpoint address="https://website.com/services/BookingService.svc" binding="wsHttpBinding"
       bindingConfiguration="TransportSecurity" contract="Services.IBookingService"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity" maxReceivedMessageSize="2000000">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

目前,我的HTTP服务仍然可以访问,但HTTPS访问只发送一个空白页面

我需要HTTP返回一个错误/页面必须由安全通道查看,HTTPS是唯一有效的


如何修复此问题?

Smithy尝试用以下内容替换端点:

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="Services.IBookingService"></endpoint>

和你的基本绑定

  <basicHttpBinding>
    <binding name="TransportSecurity" maxReceivedMessageSize="2000000">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </basicHttpBinding>


希望这能有所帮助。

在Web.Config的
部分,添加
元素。

我必须禁用IIS通过端口80的访问,但这是一种享受。谢谢D