Configuring WCF for Multiple IIS Host Identities in Sueetie

With Sueetie v4.0 shaping up to be a solid Social Media Platform for the Enterprise, I needed to be sure Sueetie could support corporate sites that support multiple IIS host names. An example would be a site accessed both externally and internally, externally at, say, http://external.coolcompany.com and internally at http://coolcompanynet.

WCF is able to support only a single base address out of the box, and errors to the server Event Log would be generated for any site whose identity does not conform to the base address specified in the Sueetie web.config’s WCF settings.  That won’t be an issue with Sueetie v4.0.

To configure Sueetie to support WCF services in a multi-host environment we’re going to make modifications to two files only, SueetieService.svc and the web.config.

SueetieService.svc

Sueetie Premium Edition includes a special "ServiceHostFactory" class that modifies how WCF Service Hosts are created. We’re going to specify that Service Host Factory class in SueetieService.svc, located at /util/services/SueetieService.svc. We’re going to add a single "Factory" element to our @ServiceHost statement. Add it exactly as you see below.

<% @ ServiceHost Language="C#" 
	Debug="true" 
	Service="SueetieService" 
	CodeBehind="~/CodeFiles/SueetieService.cs"  
	Factory="Sueetie.Components.SueetieServiceHostFactory" %>

web.config

We’re going to modify the web.config WCF settings to support multiple host endpoints. Replace the corresponding lines in your web.config with the following.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
	multipleSiteBindingsEnabled="true" />
<services>
<service name="SueetieService" 
	behaviorConfiguration="SueetieServiceAspNetAjaxBehavior">
<host>
<baseAddresses>
<add baseAddress="http://domain1.com/util/services/SueetieService.svc"/>
<add baseAddress="http://domain2.com/util/services/SueetieService.svc"/>
</baseAddresses>
</host>
	<endpoint behaviorConfiguration="SueetieServiceAspNetAjaxBehavior" 
			binding="webHttpBinding" contract="SueetieService" />
</service>
</services>

"Domain1.com" and "Domain2.com" or any additional hosts will be replaced by your site’s hosts.

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.