Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / RunTime / Hosting / WorkflowWebHostingModule.cs / 1305376 / WorkflowWebHostingModule.cs
/********************************************************************************
// Copyright (C) 2000-2001 Microsoft Corporation. All rights reserved.
//
// CONTENTS
// Workflow Web Hosting Module.
// DESCRIPTION
// Implementation of Workflow Web Host Module.
// REVISIONS
// Date Ver By Remarks
// ~~~~~~~~~~ ~~~ ~~~~~~~~ ~~~~~~~~~~~~~~
// 02/22/05 1.0 [....] Implementation.
* ****************************************************************************/
#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Web;
using System.Collections.Specialized;
using System.Threading;
#endregion
namespace System.Workflow.Runtime.Hosting
{
///
/// Cookie based rotuing module implementation
///
public sealed class WorkflowWebHostingModule : IHttpModule
{
HttpApplication currentApplication;
public WorkflowWebHostingModule()
{
WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Workflow Web Hosting Module Created");
}
///
/// IHttpModule.Init()
///
///
void IHttpModule.Init(HttpApplication application)
{
WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Workflow Web Hosting Module Initialized");
this.currentApplication = application;
//Listen for Acquire and ReleaseRequestState event
application.ReleaseRequestState += this.OnReleaseRequestState;
application.AcquireRequestState += this.OnAcquireRequestState;
}
void IHttpModule.Dispose()
{
}
void OnAcquireRequestState(Object sender, EventArgs e)
{
//Performs Cookie based routing.
WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "WebHost Module Routing Begin");
HttpCookie routingCookie = HttpContext.Current.Request.Cookies.Get("WF_WorkflowInstanceId");
if (routingCookie != null)
{
HttpContext.Current.Items.Add("__WorkflowInstanceId__", new Guid(routingCookie.Value));
}
//else no routing information found, it could be activation request or non workflow based request.
}
void OnReleaseRequestState(Object sender, EventArgs e)
{
//Saves cookie back to client.
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("WF_WorkflowInstanceId");
if (cookie == null)
{
cookie = new HttpCookie("WF_WorkflowInstanceId");
Object workflowInstanceId = HttpContext.Current.Items["__WorkflowInstanceId__"];
if (workflowInstanceId != null)
{
cookie.Value = workflowInstanceId.ToString();
HttpContext.Current.Response.Cookies.Add(cookie);
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ViewStateException.cs
- IntegerValidator.cs
- MenuItemBindingCollection.cs
- GridViewSortEventArgs.cs
- DesignerMetadata.cs
- UnconditionalPolicy.cs
- ReservationCollection.cs
- SqlIdentifier.cs
- TranslateTransform3D.cs
- ExceptionUtil.cs
- ValuePattern.cs
- FilteredReadOnlyMetadataCollection.cs
- FilteredAttributeCollection.cs
- OleDbFactory.cs
- WindowsListViewScroll.cs
- EntityCommandExecutionException.cs
- HtmlForm.cs
- Main.cs
- OpCopier.cs
- XamlSerializationHelper.cs
- BufferAllocator.cs
- EndpointDispatcherTable.cs
- Menu.cs
- XsltContext.cs
- AutomationPropertyInfo.cs
- DiscoveryEndpointElement.cs
- ListSortDescription.cs
- NativeActivityMetadata.cs
- FlowLayoutPanelDesigner.cs
- HtmlElementEventArgs.cs
- ValidationHelper.cs
- SemanticBasicElement.cs
- SystemColorTracker.cs
- BitConverter.cs
- QueryResult.cs
- SettingsAttributeDictionary.cs
- BrowserCapabilitiesFactory.cs
- XamlReaderConstants.cs
- ImageFormatConverter.cs
- ValidationManager.cs
- UriTemplateCompoundPathSegment.cs
- DictionaryEntry.cs
- SharedStatics.cs
- PauseStoryboard.cs
- ColumnCollection.cs
- ConnectionsZone.cs
- GatewayDefinition.cs
- Transform.cs
- TypeSystem.cs
- DataGridViewComboBoxCell.cs
- UIPropertyMetadata.cs
- ItemContainerGenerator.cs
- XsltCompileContext.cs
- DoubleCollection.cs
- DocumentPage.cs
- SettingsPropertyValue.cs
- TextBoxAutomationPeer.cs
- SvcMapFileSerializer.cs
- CharacterBufferReference.cs
- CryptoHelper.cs
- OleDbWrapper.cs
- TemplatePropertyEntry.cs
- FocusWithinProperty.cs
- UIElement.cs
- MaskDescriptors.cs
- XmlMemberMapping.cs
- Propagator.cs
- _SpnDictionary.cs
- PrimitiveXmlSerializers.cs
- StyleCollection.cs
- ScriptComponentDescriptor.cs
- SingleStorage.cs
- FormsAuthenticationUser.cs
- StreamWithDictionary.cs
- ResourcesGenerator.cs
- DataSpaceManager.cs
- PartitionedStream.cs
- xmlsaver.cs
- Int64KeyFrameCollection.cs
- Soap.cs
- DataProtection.cs
- BufferModesCollection.cs
- Matrix.cs
- MinimizableAttributeTypeConverter.cs
- EncryptedXml.cs
- _PooledStream.cs
- StylusButtonEventArgs.cs
- TextServicesHost.cs
- RadialGradientBrush.cs
- DataGridViewCell.cs
- XmlSerializableServices.cs
- InternalRelationshipCollection.cs
- WebPartHelpVerb.cs
- DecoderBestFitFallback.cs
- StringUtil.cs
- UIElementAutomationPeer.cs
- RtfToXamlReader.cs
- ActiveDocumentEvent.cs
- Simplifier.cs
- CompModSwitches.cs