public sealed class UserLoginSingleton
{
UserLoginCollection _userLoginCol = new UserLoginCollection();
UserLoginSingleton()
{
}
public static UserLoginSingleton Instance
{
get
{
IDictionary items = HttpContext.Current.Items;
if (!items.Contains("TheInstance"))
{
items["TheInstance"] = new UserLoginSingleton();
}
return items["TheInstance"] as UserLoginSingleton;
}
}
public void CreateUserObj(string xmlData)
{
_userLoginCol = (UserLoginCollection)_xmlUtil.Deserialize(xmlData, typeof(UserLoginCollection));
}
public UserLoginCollection getUserObj()
{
return _userLoginCol;
}
}
Usage:
Page 1.aspx
UserLoginSingleton.Instance.CreateUserObj(xml);
Pase2.aspx:
UserLoginCollection userLoginCollection = UserLoginSingleton.Instance.getUserObj();
Followed the article here: link text
I set my collection object in page 1 and then do a response.redirect or click on link to get me to page 2.aspx. However, my singleton instance has no collection object i set. How do i persist my collection object across diff pages per each session?
I know static's wont work as every instance will see the object and i want that to specific per each user.