如果 IIS 服务器不支持 https 端点,则不要包含它们
如何在安装过程中注释配置文件的元素? 即我将WCF服务安装到IIS。如果 IIS 没有 https 协议绑定,我需要在 Web.config 中注释 https 端点。 否则不要评论这个端点。
<service name="MyServer.MyDataAccessRESTService" behaviorConfiguration="MyServer.MyDataAccessRESTServiceBehavior">
<endpoint binding="webHttpBinding" contract="MyServer.IMyDataAccessRESTService"
bindingConfiguration="webHttpBinding0" behaviorConfiguration="MyDataAccessRESTServiceBehavior"
address="http://localhost/svc2Web/svc2rest.svc"></endpoint>
<endpoint binding="webHttpBinding" contract="MyServer.IMyDataAccessRESTService"
bindingConfiguration="webHttpBinding1" behaviorConfiguration="MyDataAccessRESTServiceBehavior"
address="https://localhost/svc2Web/svc2rest.svc"></endpoint>
</service>
How I can comment element of config file during the installing?
I.e. I install WCF service to IIS. If IIS does not have https protocol binding I need to comment https endpoints in Web.config.
Else do not comment this endpoint.
<service name="MyServer.MyDataAccessRESTService" behaviorConfiguration="MyServer.MyDataAccessRESTServiceBehavior">
<endpoint binding="webHttpBinding" contract="MyServer.IMyDataAccessRESTService"
bindingConfiguration="webHttpBinding0" behaviorConfiguration="MyDataAccessRESTServiceBehavior"
address="http://localhost/svc2Web/svc2rest.svc"></endpoint>
<endpoint binding="webHttpBinding" contract="MyServer.IMyDataAccessRESTService"
bindingConfiguration="webHttpBinding1" behaviorConfiguration="MyDataAccessRESTServiceBehavior"
address="https://localhost/svc2Web/svc2rest.svc"></endpoint>
</service>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会反过来做。让 web.config 的默认版本省略 HTTPS 端点。如果 IIS 中启用了 HTTPS,请使用 XmlConfig 功能向 web.config 添加新元素。您可以在此处和这里。
I would do this the other way around. Let the default version of web.config omit the HTTPS endpoint. In case HTTPS is on in IIS, add a new element to web.config using XmlConfig capabilities. You can find the sample of how to do this here and here.