WCF: Handling multiple IIS bindings - This collection already contains an address with scheme http
Environment: IIS configured for multiple bindings with different host headers.
WCF Reporting Error: This collection already contains an address with scheme http.
IIS supports specifying multiple IIS bindings per site, which results in multiple base addresses per scheme.
A WCF service hosted under a site allows binding to only one baseAddress per scheme.
Resolution (Depending on the framework used)
1. Framework 3.0
Not supported - http://msdn.microsoft.com/en-us/library/aa751841(v=vs.85).aspx
2. Framework 3.5
Using Base Address Prefix Filter - http://msdn.microsoft.com/en-us/library/bb924481.aspx
You can refer your one of the host header URI here.
<endpoint address="http://server1:81/Service1.svc/server1" binding="wsHttpBinding" contract="WcfService1.IService1" />
<endpoint address="http://server2:81/Service1.svc/server2" binding="wsHttpBinding" contract="WcfService1.IService1"/>
We need to add two end point, with respective Address (both pointing to different host headers)
3. Framework 4.0
To enable support for multiple bindings in IIS we can set ServiceHostingEnvironment’s MultipleSiteBindingsEnabled to true. This support is limited to HTTP protocol schemes.
<serviceHostingEnvironment multipleSiteBindingsEnabled=”true” >
Note: Any baseAddressPrefixFilters settings are ignored when this setting is set to TRUE.
When I try this it does not work. I get When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute.