轉載自:http://hi.baidu.com/xihzh/blog/item/14921755680c4bc0b745aeda.html
類中讀取
HttpContext.Current.Session["username"]
但是有種情況就是用到了AJAX的話在返回的方法中調用就會有問題所以要有小的改動
[AjaxMethod]//如果要訪問session請加上下面.如果還要寫session,加上面的
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]