Freigeben über


How can WCF support multiple IIS Binding specified per site ?

Background

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 – HTTP

Binding Information – IPAddress , Port, Hostheader

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.

Solution in .Net Fx 3.0: Supporting Multiple IIS Bindings Per Site

Solution in .Net Fx3.5: BaseAddressPrefixFilters

 I am updating this blog entry with a better solution support for 3.5. This one does not require you to write custom factories

Say you want to host the service over https://payroll.myorg.com:80 and https://payroll.myorg.com:9000

Step1 set the baseAddressPrefix to one of the addresses   

Example

<system.serviceModel>

<serviceHostingEnvironment>

<baseAddressPrefixFilters>

        <add prefix=” https://payroll.myorg.com:8000 ”/>

</baseAddressPrefixFilters>

</serviceHostingEnvironment>

</system.serviceModel>

Step 2 Set the endpoints in your web.config file to be absolute URIs

<services>

<service>

<endpoint address=" https:// payroll.myorg.com:8000/Service1.svc/EP1"  Binding="..." Contract="..." />

<endpoint address=" https:// payroll.myorg.com:9000/Service1.svc/EP12"  Binding="..." Contract="..." />

</service>

</services>

Solution in .Net Fx4.0: BaseAddressPrefixFilters

 Beta2 Fix

In the current  Beta2 release of the .NET Framework, we added  support for multiple site binding  . Just set the binding in IIS site and the service will inherit the address

  Final RTM Fix

In the final bits, we decided to make it an opt-in due to application compatability reasons. In order to enable multiple site binding, you need to set multipleSiteBindingEnabled to true in your application. Multiple site binding is supported only for Http protocol. The address of endpoints in the configuration file need to be complete URI. When porting your 3.0 or 3.5 workaround to 4.0 you need to keep this particular aspect.

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

Comments

  • Anonymous
    February 11, 2008
    PingBack from http://www.biosensorab.org/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site/

  • Anonymous
    December 21, 2008
    Όπως θα διαβάσατε στο forum μας το StudentGuru.gr συνεργάζεται με την Xelixis.net και παρέχει 100% δωρέαν

  • Anonymous
    February 12, 2009
    Running WCF on IIS 5 (Windows XP)

  • Anonymous
    February 12, 2009
    Running WCF on IIS 5 (Windows XP)

  • Anonymous
    February 12, 2009
    Running WCF on IIS 5 (Windows XP)