類庫中獲取Session首先要添加引用
獲取Session
復制代碼 代碼如下:
string user = (string)HttpContext.Current.Session["user"];
獲取Page
復制代碼 代碼如下:
System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler;
獲取當前 Request Response 等對象都是在這裡
復制代碼 代碼如下:
HttpResponse response = System.Web.HttpContext.Current.Response;
HttpRequest request = System.Web.HttpContext.Current.Request;