我很难在localhost上运行https休息服务器,以便在ms visual studio 2015上进行测试。常规的http REST Wcf服务器运行得很好,但是当试图通过https访问localhost时,它似乎已经关闭了(无法访问网站)。我已经阅读了the hanselman website上的说明,试图让它工作,但我觉得我错过了一个至关重要的步骤。我可能错过了(少数)设置吗?
我假设在WcfService项目属性中启用ssl时会处理证书的创建,这是正确的吗?
以下是我的Web.config文件:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<services>
<service name="WcfService.Service1" behaviorConfiguration="WcfService.Service1Behavior" >
<host>
<baseAddresses>
<add baseAddress="https://localhost/" />
</baseAddresses>
</host>
<endpoint address=""
binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity"
behaviorConfiguration="WcfService.Service1EndpointBehavior"
contract="WcfService.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSecurity">
<security mode="Transport" />
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WcfService.Service1EndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
IIS特定服务器部署如下所示:
...
<site name="WcfService" id="2" serverAutoStart="true">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\test\documents\visual studio 2015\Projects\MyProject\WcfService" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:2444:localhost" />
<binding protocol="https" bindingInformation="*:44378:localhost" />
</bindings>
</site>
...
&#13;
非常感谢所有帮助!