我花了几周的时间试图找出为什么将.NET 4.0升级到4.5.2时,我的WCF服务在通过https访问时返回404,而不是http。在升级之前,它通过http和https工作。
这是一个ASP.NET网站(非Web应用程序)
这是Services.svc
<%@ ServiceHost Language="VB"
Debug="true"
Service="Services"
CodeBehind="~/App_Code/WCF_Services.vb"
Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
这是web.config
<system.serviceModel>
<services>
<service name="Services">
<endpoint address="" binding="webHttpBinding"
contract="IServices" behaviorConfiguration="EdpHelpBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="EdpHelpBehavior">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"
aspNetCompatibilityEnabled="true" />
答案 0 :(得分:0)
您是否使用绑定配置进行了测试?
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSec">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
答案 1 :(得分:0)
我们有一个生产服务器和一个开发服务器。我尝试了对web.config文件进行数小时和数小时的更改,以及对cmd窗口中的IIS和asp_reg命令进行了一些更改。直到我向开发域添加了ssl证书才开始工作。生产服务器已经有了这个,所以我不认为这是原因。它是web.config更改的组合,另外还添加了修复它的证书。完成后我们将webconfig成功复制到生产站点。
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="ServiceModel" />
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv2.0" />
</modules>
<directoryBrowse enabled="false" />
</system.webServer>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />