WCF Service error: "This collection already contains an address with scheme http."

\"This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.\" is a Windows Communication Foundation (WCF) error message indicating you are trying to add an already existing binding. By default the web service listens to all in IIS configured host headers. A host header is the website address, for example example.com and 'www.example.com'. If this is not correctly added to the `web.config` file, the following error is thrown...
Published on Tuesday, 27 December 2011

Server Error in MultipleBindings Application

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

With a correctly configured web.config it's good possible to host the service on two URL's, for example https://payment.example.com:443 and https://payment.example.com:9000.

Fixes for "WCF Server Error in MultipleBindings Application" in differnet .NET Framework versions

Different .NET Framework versions have different solutions for this error.

Fix for .NET 2.0/3.0/3.5

  1. Set a baseAddressPrefix on one of the two URL's in the web.config file:
<system.serviceModel>
  <servicehostingenvironment>
    <baseaddressprefixfilters>
      <add prefix="https://payment.example.com:443"/>
    </baseaddressprefixfilters>
  </servicehostingenvironment>
</system.serviceModel>
  1. Add both endpoint URL's as absolute URL's in the web.config file:
<services>
  <service>
    <endpoint 
      address="https://payment.example.com:443/Service1.svc/EP1"
      Binding="..."
      Contract="..." />
    <endpoint address="https://payment.example.com:9000/Service1.svc/EP12"
      Binding="..."
      Contract="..." />
  </service>
</services>

Fix for ASP.NET 4.0/4.5

ASP.NET 4.0/4.5 has a multipleSiteBindingsEnabled web.config configuration optie available to services multiple site bindings. Keep this in mind when you port your 3.0/3.5 application to 4.0.

<servicehostingenvironment multipleSiteBindingsEnabled="true" />

For ASP.NET 4.0/4.5 you first must install NET-HTTP-Activation and NET-WCF-HTTP-Activation features in IIS. Verify the *.svc handler is added to IIS after installation.

References and more information: