WCF service error: This collection already contains an address with scheme https. There can be at most one address per scheme in this collection.
After moving some WCF services from one server to another, I was welcomed by the following error message:
With ASP.NET 4.0, add the following lines to your web.config:
With ASP.NET 2.0/3.0/3.5, add the following lines to your web.config:
IIS bindings provide two pieces of information – binding protocol and binding information. Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site.
Example
"This collection already contains an address with scheme https. There can be at most one address per scheme in this collection."“Googling” the error brought me a solution soon, but what caused this error message?
The solution
You can resolve this error by changing the web.config file.With ASP.NET 4.0, add the following lines to your web.config:
<system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel>
With ASP.NET 2.0/3.0/3.5, add the following lines to your web.config:
<system.serviceModel> <serviceHostingEnvironment> <baseAddressPrefixFilters> <add prefix="https://dev.server.be"/> </baseAddressPrefixFilters> </serviceHostingEnvironment> </system.serviceModel>
The reason
IIS has web sites, which are containers for virtual applications which contain virtual directories. The application in a site can be accessed through one or more IIS binding.IIS bindings provide two pieces of information – binding protocol and binding information. Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site.
Example
Binding protocol – HTTPThe problem is that the IIS server was configured to support multiple bindings, which results in multiple base addresses per scheme. This brings WCF into trouble. A WCF service hosted under a site allows binding to only one baseAddress per scheme.
Binding Information – IPAddress , Port, Hostheader