【问题标题】:WCF only over HTTPS SVC hosted inside MVC projectWCF 仅通过托管在 MVC 项目中的 HTTPS SVC
【发布时间】:2012-02-11 05:38:43
【问题描述】:

我已将 WCF .svc 文件添加到我的 MVC3 项目中,我正在尝试阻止通过 HTTP 访问该服务。

通过下面的配置,我的服务可以在一个端口上通过 https 使用,然后在另一个端口通过 http 使用。

如何防止这种情况发生?

谢谢

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="TS">
                    <security mode="Transport">
                        <transport clientCredentialType="None"/>
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <services>
            <service name="Endpoints" behaviorConfiguration="Default">
                <endpoint address="https://localhost:44301/Services/Endpoints.svc" binding="basicHttpBinding"  bindingConfiguration="TS" contract="UkerLtd.Services.IEndpoints"></endpoint>
                <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="Default">
                    <serviceMetadata httpGetEnabled="false" httpsGetUrl="https://localhost:44301/Services/Endpoints.svc" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
    </system.serviceModel>

【问题讨论】:

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


    【解决方案1】:

    您可以评论或删除 IMetadataExchange 的第二个端点,
    因为它是针对同一个服务的,所以元数据将被
    服务行为/服务元数据中的 httpsGetEnabled="true"。

    否则您可以“设置 IIS 以要求 SSL”,但因为它不是一个选项..

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-16
      • 2012-06-02
      • 1970-01-01
      • 2015-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多