Saturday, September 15, 2012

Singleton Session

public class SingletonSession
{
// private constructor
private SingletonSession()
{

}

// Gets the current session.
public static SingletonSession Current
{
get
{
SingletonSession session =
(SingletonSession)HttpContext.Current.Session["__SingletonSession__"];
if (session == null)
{
session = new SingletonSession();
HttpContext.Current.Session["__SingletonSession__"] = session;
}
return session;
}
}

// **** add your session properties here, e.g like this:

public Guid UserId { get; set; }
public string UserName { get; set; }
public string AccountNo { get; set; }
public MembershipUser User { get; set; }
}

}

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates