0

I would like to have a WCF Service that supports HTTP or HTTPS. Link1 and link2 have been very helpful and I managed to modify web.config to work for both HTTP and HTTPS

    <service name="Service">
       <endpoint address="" contract="IService" binding="webHttpBinding" bindingConfiguration="wbBind" behaviorConfiguration="web" />
       <endpoint address="" contract="IService" binding="webHttpBinding" bindingConfiguration="wbsBind" behaviorConfiguration="web" />
  </service>

  <binding name="wbBind">
       <security mode="None"></security> 
  </binding>
  <binding name="wbsBind">
      <security mode="Transport"></security> 
  </binding>

This works just fine when I have two IIS bindings Site bindings

But if I delete one of the bindings (http for example) Only https binding

then https will also stop working (or the other way around). Can this be fixed?

1 Answers1

0

only http binding config will be like this:

    <service name="Service">
       <endpoint address="" contract="IService" binding="webHttpBinding" bindingConfiguration="wbBind" behaviorConfiguration="web" />
  </service>

  <binding name="wbBind"/>

remember you should change the web config in order to have just http or https bindings.

Mohammad
  • 2,724
  • 6
  • 29
  • 55
  • I know how the config should look for just http...or just https; and I also know to support http and https (If the number of site bindings in IIS is equal to the number of endpoints for a service in web.config) Now, what I would like to have is a general config that supports both http and https, regardless of the number of site bindings in IIS. So if a user has a http site binding then the website will work with http; if he has a https binding, it will work with https; and if he has http and https, it will work with both. – Luca Andrei Mar 12 '18 at 08:30
  • that's simple. just set both http and https binding in your iis and then you are good to go. remember if you want just http you should remove the https part. there is no way to make it work the way you want. you can achive that in web api but not in wcf. – Mohammad Mar 12 '18 at 08:44