我需要在开发和部署期间在http和https之间切换。
为此,我需要在web.config中进行以下更改:
<behaviors>
<serviceBehaviors>
<behavior name="DirectInstallHelperServiceBehavior">
<!-- need to change to <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"> -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false">
</serviceMetadata>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding>
<!-- need to add the following, but don't know how
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
-->
</binding>
</webHttpBinding>
</bindings>
所以我尝试在Web.Release.config中添加以下行:
<behaviors>
<serviceBehaviors>
<behavior name="DirectInstallHelperServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" xdt:Transform="setAttribute(httpsGetEnabled, httpGetEnabled)" xdt:Locator="Match(name)"></serviceMetadata>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding>
<security mode="Transport" xdt:Transform="InsertAfter(/configuration/system.serviceModel/bindings/webHttpBinding/binding)">
<transport clientCredentialType="Basic"/>
</security>
</binding>
</webHttpBinding>
</bindings>
但是我做错了,因为当我将服务发布到我的文件系统时,我仍然看到web.config的开发http版本。 任何帮助表示赞赏。
答案 0 :(得分:8)
将xdt:Transform
值更改为SetAttributes
。并删除xdt:Locator
,因为没有名称属性。
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" xdt:Transform="SetAttributes"></serviceMetadata>