IIS7.5 and ASP.NET MVC2: Cache/Session sharing

asp.net-mvccacheiis-7.5

Is there a way to share the sessions and the cache between multiple IIS7.5 servers that use ASP.NET MVC 2 ?

Something like that what we can easily do with Rails/Django and a memcached server.

It looks like the 'Web Farm mode' in the IIS control panel does that, but I'm not sure.

Best Answer

You can actually use memcached :)

For sessions, there has always been a provider model so you can implement your own storage if you don't like the built-in in-process memory or SQL Server options. See this tutorial: http://msdn.microsoft.com/en-us/library/ms178587.aspx

For the built-in cache API, such an extensible provider model has been added to ASP.NET 4.0: http://www.devproconnections.com/article/development/Implementing-Custom-Cache-Providers-in-ASP-NET-4-0/2.aspx

For older version, you can use a different API like suggested here: https://stackoverflow.com/questions/873355/how-to-implement-a-custom-cache-provider-with-asp-net-mvc

Btw, I like the enyim.com Memcached Client for .NET.