0

我已将 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>
4

1 回答 1

0

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

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

希望这可以帮助。

于 2013-05-09T13:40:02.773 回答