Supporting Multiple IIS Site Bindings
When hosting a Windows Communication Foundation (WCF) service under Internet Information Services (IIS) 7.0, you may want to provide multiple base addresses that use the same protocol on the same site. This allows the same service to respond to a number of different URIs. This is useful when you want to host a service that listens on
http://contoso.com. It is also useful to create a service that has a base address for internal users and a separate base address for external users. For example:
This functionality is only available using the HTTP protocol.
Multiple Base Addresses
This feature is only available to WCF services that are hosted under IIS. This feature is not enabled by default. To enable it you must add the
multipleSiteBindingsEnabled attribute to the <
serviceHostingEnvironment> element in your Web.config file and set it to
true, as shown in the following example.
When hosting a WCF service under IIS, IIS creates one base address for you based on the URI to the virtual directory that contains the application. You can add additional base addresses that use the same protocol by using Internet Information Services Manager to add one or more bindings to your Web site. For each binding specify a protocol (HTTP or HTTPS), an IP address, a port, and a host name. For more information about using Internet Information Services Manager, see IIS Manager (IIS 7). For more information about adding bindings to a site, see Create a Web Site (IIS 7)
Specifying multiple base addresses for the same site affects the content of the WCF Help page, importing schema, and the WSDL/MEX information generated by the service. The WCF Help page displays the command line to use to generate a WCF client that can communicate with the service. This command line contains only the first address specified in the IIS binding for the Web site. Similarly when importing schema, only the first base address specified in the IIS binding is used. WSDL and MEX data contain all the base addresses specified in the IIS bindings.
This means that if a service has two base addresses, one for internal users and one for external users, both are specified in the WSDL/MEX information generated by the service.