Wednesday, December 7, 2011

Storing Session State in Windows Server AppFabric Cache


Today I am going to post about how to make use of Windows Server AppFabric Cache as Session Store for the Asp.Net Web Application.

This can be achieved by following simple steps

    1)  Add the reference of following Assembly from the following location
a.  Microsoft.ApplicationServer.Caching.Core.dll
b.   Microsoft.ApplicationServer.Caching.Client.dll
The above 2 assemblies can be located at the following locations –


    2)  Add the following entry at the ConfigSections of the Web.Config

<section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
            Microsoft.ApplicationServer.Caching.Core, Version=,
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"

    3)  Inside the configuration tag, add the following entry

        <host name="a4ml01382" cachePort="22233"/>
      <securityProperties mode="None" protectionLevel="None" />
      <transportProperties connectionBufferSize="131072" maxBufferPoolSize="268435456"
                         maxBufferSize="8388608" maxOutputDelay="2"  channelInitializationTimeout="60000" receiveTimeout="600000"/>


    4)  Inside the System.Web tag, add the following entry

 <sessionState mode ="Custom" compressionEnabled="true"customProvider="AppFabricCacheSessionStoreProvider" cookieless="false">
          cacheName="AspNetCacheName" />

    5)   You are all set to go from Client Asp.Net Application for making use of AppFabric cache   as Session store.. Now you need to do the following 2 steps to ensure that it works

a)  Ensure that the AppFabric Cache service is running
b)  Ensure that you have created the cache with the name – AspNetCacheName – because this is the place where in the session data is stored( We have explicitly named this ‘AspNetCacheName ‘ in step 4 )

I hope this helps!.


No comments: