转载自:http://hi.baidu.com/xihzh/blog/item/14921755680c4bc0b745aeda.html
类中读取
HttpContext.Current.Session["username"]
但是有种情况就是用到了AJAX的话在返回的方法中调用就会有问题所以要有小的改动
[AjaxMethod]//如果要访问session请加上下面.如果还要写session,加上面的
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]