Table of Contents

This blog post drills down on the various hosting capabilities of WCF and WF in .NET 4 and for Window Server AppFabric as introduced in in the Introduction to AppFabric blog entry.

When referring to hosting, I am discussing the features of the “application environment”, which enables execution and management of the applications.

The .NET 4 for WCF Web services one focus was on making the application easier to configure and manage. For Workflow (WF) Web services, we integrated the “application environment” with WAS (Windows Process Activation Service) so that you could deploy, execute and manage WF services.

Windows Server AppFabric extends the WAS “application environment” to provide two additional hosting capabilities, namely  “Always Running” and “Scheduled Start”.

I will describe these hosting features in detail in this post, so let’s start with the improvements in .NET 4.

.NET 4 Hosting Enhancements

1)     Config Based Activation (CBA):

Today when hosting web applications containing services, you need to deploy an additional “.svc” file, describing metadata and information about the services. When organizations/applications have large number of services, there is an inherit explosion of files causing a management overhead. To address this problem, we introduced the config based activation feature which allows registration of the services in the web.config files, eliminating the need for a .svc file.


a.     Add the service registration to the web.config file of your web application.

In the example below, we register two services, the CreditCheckService and the PaymentService. In addition the Payment/PaymentService.svc specifies a customfactory that can be used for activation.

        <add relativeAddress= "CreditCheckService.svc" service="Microsoft.ServiceModel.Samples.CreditCheckService"/>
        <add relativeAddress= "Payment/PaymentService.svc" service="Microsoft.ServiceModel.Samples.PaymentCheckService" Factory=”CustomFactory”/>


Note: You have the option of using either Service Config Editor or Visual Studio Intellisense to configure the application.

More details about this feature can be found here;



2)     Support Multiple Site Bindings:  

Many hosters and organizations host their web application over multiple ports and hostnames. This makes their service accessible over multiple addresses. For example the following addresses resolve to the same service.



The URLs above require specifying multiple site bindings in IIS. Lack of this support for this feature in the WCF runtime was an adoption blocker in the 3.0 release of the .NET framework. In .NET 3.5, we made some incremental improvements through  baseAddressPrefixFilters. In .NET 4, we have addressed more of this feature, which has significantly eased the shared hosting deployment issues.


a.     Configure Site: Configure IIS site binding with the required host headers.

b.     Enable Application: Configure the application web.config file to enable multiple site bindings. See example below.

 <serviceHostingEnvironment multipleSiteBindingsEnabled=”true”>


Note: Only multiple of http/https site bindings are supported. i.e. TCP and other protocols are not currently supported

More details about this feature can be found here;



3)     Enable Extension-less URLs

There are scenarios when you might want to deploy your web service without extensions in the URL say for example, a WCF REST RSS service deployed with these URL



We leveraged System.Web.Routing feature and added a new System.ServiceModel.Activation.ServiceRoute API to enable the registration of WCF services. This enabled us to extend an API customers were already familiar with it to WCF Services.


The example below enables activation of a WCF REST service over the URI

a.     Enable runAllManagedModulesForAllRequests

Add the following configuration to the application web.config file. Note: the Visual Studio web application template includes this by default.

<modules runAllManagedModulesForAllRequests="true">

b.     Register the Route Handler/Module

<add name="UrlRoutingModule"
                   System.Web.Routing, Version=,
                   PublicKeyToken=31BF3856AD364E35" />
        <add name="UrlRoutingHandler"
              verb="*" path="UrlRouting.axd"
                  System.Web, Version=, Culture=neutral,
                  PublicKeyToken=b03f5f7f11d50a3a" />  


c.      Register the service either in global.asax or AppInitiate() method deployed to App_Code directory.

protected void Application_Start(object sender, EventArgs e)
 {                 RouteTable.Routes.Add(new ServiceRoute("movies", new WebServiceHostFactory(), typeof(Movies)));


More details about this feature can be found here – 


4)     Workflow in WAS

As part of providing the “application environment” for WF, we enabled

1)     Activation of declarative .xamlx Workflows when deploy to WAS

2)     Continued execution by identifying instance performing work and reporting it to the hosting environment. This ensures that the host process is not unnecessarily recycled.


Use the WCF workflow Service Application template to develop WF application to be hosted in WAS/Windows Server AppFabric. These templates will generate .XAMLX resources which are directly hostable in WAS.

Note: if you have custom activities which need to be deployed along with the application, then they need to reference it in the system.web.compilation <assemblies> element.