现在的位置: 首页 > 综合 > 正文

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

2013年03月10日 ⁄ 综合 ⁄ 共 388字 ⁄ 字号 评论关闭

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一般情况下是默认引用的

抱歉!评论已关闭.