Sunday, April 22, 2012

Allow WCF multiple Binding on IIS

IIS supports specifying multiple IIS bindings per site. A WCF service hosted under a site allows binding to only one baseAddress per scheme.
I want to host service with multiple binding without custom factories.
http://seesaudi.com, http://seesaudimor.com

I found solution:
Solution in .Net 3.5:
Set the baseAddressPrefix to one of the addresses:


        <system.serviceModel>
        <serviceHostingEnvironment>
        <baseAddressPrefixFilters>
                <add prefix="http://seesaudi.com"/>    
        </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        </system.serviceModel>

  1. Set the endpoints in your web.config file to be absolute URIs:

  2.    <services>
          <service>
            <endpoint address="http://seesaudi.com/Service1.svc/e1"  Binding="..." Contract="..." />
           <endpoint address="http://seesaudimor.com/Service1.svc/e2"  Binding="..." Contract="..." />
          </service>
       </services>
Solution in .Net 4.0: 
  In order to enable multiple site binding, you need to set multipleSiteBindingEnabled to true in your application.

   <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />  

No comments: