asp.net在自定义的类中引用Response,Request,Server等对象

asp.net在自定义的类中引用Response,Request,Server等对象只需直接写System.Web.HttpContext.Current.Response即可,类似的有

System.Web.HttpContext.Current.Request

System.Web.HttpContext.Current.Server

System.Web.HttpContext.Current.Session

例如:

System.Web.HttpContext.Current.Response.Write();

System.Web.HttpContext.Current.Request.QueryString();

一般情况下可以直接使用HttpContext.Current.Response.Write()即可,因为命名空间System.Web一般情况下是默认引用的