把对象存入session后,取出来要转换:
CommonUserInfo userinfo = new CommonUserInfo(); Session["userinfo"] = userinfo; CommonUserInfo user = (CommonUserInfo)Session["userinfo"]; //下面这种方法也行 CommonUserInfo user1 = Session["userinfo"] as CommonUserInfo;
另外有一篇讲session的文章,很详细,但是也太复杂,现在用不上:会话状态Session