Velocity CTP3 Set up for ASP.NET Session State

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 asp.net session state provider that is actually a *very* compelling option in my opinion for managing asp.net 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.  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.

!(/images/michelotti/velocity-ctp3-set-up-for-asp.net-session-state/09748c14-o_CacheHostConfig.png)

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.  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.

posted on Friday, August 14, 2009 3:46 AM Print

This article is part of the GWB Archives. Original Author: Steve Michelotti

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.