Windows Workflow Foundation in ASP.NET

Working with Windows Workflow Foundation (WWF) in ASP.NET presents an interesting challenge. When you read all of the literature on WWF you notice that it is an Asynchronous model of programming where you call into the workflow and the workflow calls back into your application using events. In ASP.NET this type of functionality does not work since the page executes and returns and does not hang around. If you dig deeper into the SDK you will find that Microsoft has a solution for this. Since WWF is dependent upon the host “hosting” it’s runtime it is the runtime that controls the threading and lifetime of WWF and the workflow itself. In the System.Workflow.Runtime.Hosting namespace is the ASPNetThreadingService class which provides the default implementation of SynchronousDispatchService for the ASPNET host. By adding this service to the Workflow runtime you can in effect make WWF synchronous causing calls to the workflow to wait around till you events are handled. There are a few more things that you have to do to get WWF to work in ASP.NET and they all are done in your web.config file. Below is what your web.config file should look like in order to get WWF to work. 

<?xml version=”1.0″?> 

<configuration xmlns=”″> 


      <section name=”WorkflowRuntime” type=”System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/> 






      <add name=”WorkflowHost” type=”System.Workflow.Runtime.Hosting.WorkflowWebHostingModule, System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> 


<compilation debug=”true”> 


      <add assembly=”System.Workflow.Activities, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/> 

      <add assembly=”System.Workflow.ComponentModel, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/> 

      <add assembly=”System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/> 




<WorkflowRuntime UnloadOnIdle=”true”> 


   <add type=”System.Workflow.Runtime.Hosting.ASPNetThreadingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> 

   <add type=”System.Workflow.Runtime.Hosting.SqlTimerService, System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ ConnectionString=”Initial Catalog=WorkflowTimer;Data Source=(local);Integrated     Security=SSPI;”/> 

   <add type=”System.Workflow.Runtime.Hosting.SqlStatePersistenceService, System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ ConnectionString=”Initial Catalog=WorkflowPersistence;Data Source=      (local);Integrated Security=SSPI;”/> 

   <add type=”System.Workflow.Runtime.Hosting.SqlTrackingService, System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ ConnectionString=”Initial Catalog=WorkflowTracking;Data Source=(local);Integrated Security=SSPI;” IsTransactional=”false” UseDefaultProfile=”true” TrackXomlDocument=”True”/> 




Leave a Reply

Your email address will not be published. Required fields are marked *