2012-02-10 30 views
0

如何在安裝期間評論配置文件的元素? 也就是說我將WCF服務安裝到IIS。如果IIS沒有https協議綁定,我需要在Web.config中評論https端點。 否則不要評論此端點。如果IIS服務器不支持它們,請不要包含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> 

回答

1

我會這樣做的另一種方式。讓web.config的默認版本省略HTTPS端點。在IIS中啓用HTTPS的情況下,使用XmlConfig功能將新元素添加到web.config。你可以找到如何做到這一點的樣本herehere

+0

Thnx,作爲一種方式..有一個缺點。我不知道安裝程序中的確切字符串。我只知道我需要的http或/和https。該字符串包含更多元素... – Oleg 2012-02-10 13:51:03