i made one property like this :
public static List<Message> _SessionStore;
public static List<Message> SessionStore
{
get
{
if(HttpContext.Current.Session["MyData"]==null)
{
_SessionStore = new List<Message>();
}
return _SessionStore;
}
set { HttpContext.Current.Session["MyData"] = _SessionStore; }
}
I want to add value SessionStore.Add() and get SessionStore.Where()
but i got error while doing this Add And Get
first i did SessionStore.Add(comment); somewhere then i got this error
List<Message> msglist = HttpContext.Current.Session["MyData"] as List<Message>;
if(msglist.Count>0)
i am not able access msglist
can anybody fix my property in way that i can use this List from anypage to add and get values
Seems you forgot to put the
SessionStoreinto the ASP.NET session, e.g:BTW: I think the
_SessionStorefield is not required. This should be enough:And then, where you want to use the list of messages, you should access it via the
SessionStoreproperty, instead of viaHttpContext.Current.Session: