Using The Windows Server AppFabric Cache with ASP.NET

It appears that I have lost some of my blog posts.  I am reposting this blog post which originally appeared back in May.

Did you know that you can use the AppFabric Cache with ASP.NET?  AppFabric Cache provides an ASP.NET session state provider.  There are a number of reasons that you would want to consider using the AppFabric Cache instead of other caching technologies, including the built in ASP.NET caching.

The AppFabric Cache provides a number of benefits to ASP.NET programmers.  When web applications need to maintain state, especially across a Web Farm, or needs to maintain objects across restarts AppFabric Cache provides the out of process, distributed highly available functionality you require.  In addition, because of the distributed nature of the cache you no longer need to worry about sticky routing (getting the client back to the same machine as their cached objects).  You also no longer need to add additional code and incur the overhead of storing state in a database.  By keeping activity oriented objects closer to the consuming logic you can eliminate the overhead and increase performance of your application.

To utilize the AppFabric Cache ASP.NET session state provider open your applications' Web.Config file and enter the following XML fragment.

 <system.web>
    <sessionState mode="Custom" customProvider="SessionStoreProvider">
        <providers>
            <add name="SessionStoreProvider" type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider,  Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral,  PublicKeyToken=31bf3856ad364e35" />
        </providers>
    </sessionState>
</system.web>