在部署期间更改 web.config
我需要在开发和部署期间在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 版本。 任何帮助表示赞赏。
I need to switch between http and https during development and deployment.
To do that, I need to make the following changes in 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>
So I try to add the following lines in 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>
But I am doing it wrong because when I publish the service to my filesystem, I still see the development http version of web.config.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
xdt:Transform
值更改为SetAttributes
。并删除xdt:Locator
因为没有 name 属性。Change your
xdt:Transform
value toSetAttributes
. And removexdt:Locator
since there is no name attribute.