WCF: Handling multiple IIS bindings
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 - https://msdn.microsoft.com/en-us/library/aa751841(v=vs.85).aspx
2. Framework 3.5
Using Base Address Prefix Filter - https://msdn.microsoft.com/en-us/library/bb924481.aspx
Step1.
<baseAddressPrefixFilters>
<add prefix="https://server1:81/"/>
</baseAddressPrefixFilters>
You can refer your one of the host header URI here.
Step2.
<endpoint address="https://server1:81/Service1.svc/server1" binding="wsHttpBinding" contract="WcfService1.IService1" />
<endpoint address="https://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.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled=”true” >
</serviceHostingEnvironment>
</system.serviceModel>
Note: Any baseAddressPrefixFilters settings are ignored when this setting is set to TRUE.
Comments
- Anonymous
October 06, 2013
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.