ASP.NET MVC – Flash Messages Without Sessions

asp.net-mvcc

I'm developing a web application for Windows Azure using ASP.NET MVC 4. I would like to enforce one restriction in the architecture: do not use Session.

To achieve availability on Azure, and since there is no sticky sessions, I would need to store the session data in some central service, probably either SQL Azure or the Caching Service.

I would rather avoid sessions on the SQL database to avoid the increased latency, and the caching service on Azure is very expensive for the ammount of memory offered.

On the other hand, I would like to have the ability to easily pass Flash-style messages among redirects. TempData is the recommended way to do this, but by default it uses the session object.

So I would like to know:

  1. Is there an alternative way to use TempData that doesn't require sessions or shared data between servers? Cookies perhaps?
  2. Is there a better alternative I'm overlooking?

Best Answer

I worked with Azure for almost 2 years, I had dreams of building my own caching service using an Azure worker role and something like memcached. I never got around to it but it still sounds like fun, and I think it would meet your needs.

Steve Marx (former azure evangelist) wrote about it on his blog a while back...

http://blog.smarx.com/posts/memcached-in-windows-azure