Popular Posts

Wednesday, August 1, 2012

Session variables in ASP.NET MVC - Stack Overflow

Singleton session wrapper around Session Object .... Nice but possibly not thread safe? [Serializable] public sealed class SessionSingleton { #region Singleton private const string SESSION_SINGLETON_NAME = "Singleton_502E69E5-668B-E011-951F-00155DF26207"; private SessionSingleton() { } public static SessionSingleton Current { get { if ( HttpContext.Current.Session[SESSION_SINGLETON_NAME] == null ) { HttpContext.Current.Session[SESSION_SINGLETON_NAME] = new SessionSingleton(); } return HttpContext.Current.Session[SESSION_SINGLETON_NAME] as SessionSingleton; } } #endregion public string SessionVariable { get; set; } public string SessionVariable2 { get; set; } // ... }

Session variables in ASP.NET MVC - Stack Overflow:

'via Blog this'

No comments:

Post a Comment