ASP.NET中在自定义类中使用Session,Request,Response,Server

来源:互联网 发布:域名备案需要多久 编辑:程序博客网 时间:2024/05/19 02:06

方法1:using System.Web;
HttpContext.Current.Session["a"]="hello";

另:
需要你先定义
public System.Web.SessionState.HttpSessionState Session;
public System.Web.HttpResponse Response;
public System.Web.HttpServerUtility Server;
public System.Web.HttpRequest Request;
然后在用
System.Web.SessionState.HttpSessionState mys=HttpContext.Current.Session;
if(mys["SessionID"]==null||mys["SessionID"].ToString().Length==0)
{
return "1";
}

Request,Response,Server 同Session一样的用法