Velocity CTP3 Set up for ASP.NET Session State

Historically I have always viewed ASP.NET session state as "pure evil." In-proc session state is about as unreliable as you can get given that you can have timeouts, ASP.NET might recycle itself, IIS might get bounced, no scalability, and cannot work in a web farm.  SQL Session state is very resilient and works in web farm scenarios but the performance is not good and at that point you might as well be better off writing your own strongly-typed data access layer rather than blobbing everything in and out of the database.  ASP.NET state server is the "middle man" of the various options but it's not very fault tolerant. As part of Microsoft's Velocity distributed cache they are providing an session state provider that is actually a very compelling option in my opinion for managing session state – more compelling than any of the traditional three choices.  It's an in-memory distributed cache and it provides both high performance as well as robust fault tolerance potentially giving the best of both worlds.

I recently set up Velocity CTP3 in my development environment and there were a couple of minor gotchas.  Many of the samples on the web were either incomplete or outdated (i.e., based on previous versions prior to CTP 3).  The links I found most helpful (in addition to the Velocity help file) to get everything set up were:  Build Better Data-Driven Apps With Distributed Caching, How to: Configure a Session State Provider, and Andrea Col's Blog.  Putting all these links together, I was able to get it working.  This post will walk through all of the set up steps in a single place.

Step 1 – Download and run installer

Download Velocity CTP 3 from this location.

Step 2 – Accept firewall defaults

Step 3 – Cache Host Configuration

Create a new database called "Velocity" in SQL Server Management Studio. On the Cache Host Configuration screen, specify these values:

  • Storage Location type: SQL Server database
  • Connection string: data source=;Initial Catalog=Velocity;Integrated Security=SSPI
  • Cluster Name: "DevCluster" (this could really be anything)
  • Cluster Size:  Small (1-4)

Leave all other defaults.

Step 4 – Configure with PowerShell

Start PowerShell Administration Tool found in the "Microsoft Distributed Cache" fold in Program Files off the Start menu.  The first time you run it can you choose "A" for always run software from this untrusted publisher.

Execute:  Start-CacheCluster

Execute:  New-Cache -CacheName ASPNETSessionCache -TTL 60

For verification you can look at the statistics for the cache you just created:


Execute:  Get-CacheStatistics -CacheName ASPNETSessionCache

Step 5 – Configure web.config

The best reference I found for the web.config for CTP3 is here.  You can copy/paste that and either leave as is or tweak if desired.  For example, you might want to change config values in the sessionState section for cookieless, etc. depending on your scenario.

Hope this helps ease the set up process.