I have a list that I put in session:
Session.Add(\"SessionList\", mylist);
How to retrieve it back from the session?
var list = Session["SessionList"] as List;
if (list != null){
// blah...
}
I prefer to use the as keyword since there is no 100% guarantee that the Session will contain the list (due to application pool refresh, website being restarted, etc). Gives you that extra bit of defence to avoid a NullReferenceException.