<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>TomsBlog</title>
    <link>http://www.toms-blog.com/tags/iis/index.xml</link>
    <description>Recent content on TomsBlog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-uk</language>
    <atom:link href="http://www.toms-blog.com/tags/iis/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>WCF services and multiple bindings IIS</title>
      <link>http://www.toms-blog.com/post/wcf-services-and-multiple-bindings-iis/</link>
      <pubDate>Mon, 04 Mar 2013 17:17:42 +0000</pubDate>
      
      <guid>http://www.toms-blog.com/post/wcf-services-and-multiple-bindings-iis/</guid>
      <description>&lt;p&gt;When you have mutlitple bindings in IIS and have a WCF Service defined you may get the bellow error:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“This collection already containes an address with scheme http. There can be at most one address per scheme in this collection.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This happens when you have mutlitple bindings on the IIS Web Site i.e. HTTP and HTTPS.&lt;/p&gt;

&lt;p&gt;If you have .NET 4.0 installed and are on Server 2008 or later you can add a directive to your web.config to allow multiple bindings.&lt;/p&gt;

&lt;p&gt;Add &lt;strong&gt;multipleSiteBindingsEnabled=”true”&lt;/strong&gt; to &lt;strong&gt;serviceHostingEnvironment&lt;/strong&gt; like below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;serviceHostingEnvironment aspNetCompatibilityEnabled=”true” multipleSiteBindingsEnabled=”true”&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then you can add multiple endpoints to the service definition.&lt;/p&gt;

&lt;p&gt;So if you want your service to work on HTTP and HTTPS you need 2 endpoints, the HTTP endpoint can look like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;endpoint address=”” behaviorConfiguration=”KBServiceAspNetAjaxBehavior” binding=”webHttpBinding” contract=”CustomerService” /&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now your HTTPS endpoint needs to be bound to HTTPS by using bindingConfiguration directive:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;endpoint address=”” behaviorConfiguration=”KBServiceAspNetAjaxBehavior” binding=”webHttpBinding” bindingConfiguration=”webBindingHTTPS” contract=”CustomerService” /&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now define your bindingConfiguration:&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #f0f3f3&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span&gt;&lt;/span&gt;&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;bindings&amp;gt;&lt;/span&gt;
	&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;webHttpBinding&amp;gt;&lt;/span&gt;
		&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;binding&lt;/span&gt; &lt;span style=&#34;color: #330099&#34;&gt;name=&lt;/span&gt;&lt;span style=&#34;color: #CC3300&#34;&gt;”webBindingHTTPS”&lt;/span&gt;&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;gt;&lt;/span&gt;
			&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;security&lt;/span&gt; &lt;span style=&#34;color: #330099&#34;&gt;mode=&lt;/span&gt;&lt;span style=&#34;color: #CC3300&#34;&gt;”Transport”&lt;/span&gt;&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;gt;&amp;lt;/security&amp;gt;&lt;/span&gt;
		&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;/binding&amp;gt;&lt;/span&gt;
	&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;/webHttpBinding&amp;gt;&lt;/span&gt;
&lt;span style=&#34;color: #330099; font-weight: bold&#34;&gt;&amp;lt;/bindings&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If you set Security mode to transport this means the binding will be encrypted and bound to HTTPS.&lt;/p&gt;

&lt;p&gt;You should now be able to access you WCF services on both HTTP and HTTPS&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>