ASP.NET出错-当前上下文中不存在名称"Response" .

      Page.Response属性只有在页面代码中,或者说在继承自: System.Web.UI.Page的类中才有。其他即使using System.Web.UI 也无法使用Page.Response属性。否则编译时报错:当前上下文中不存在名称"Response"

      解决方法:可以用System.Web.HttpContext.Current.Response来代替,效果是一样的。

      同样的,ASP.NET报错误:当前上下文中不存在名称“Server”

      解决方法:可以用System.Web.HttpContext.Current.Server来代替

类中不包含Response.Write方法,怎么能输出呢?如果你在某页面中调用这个方法的话,System.Web.HttpContext.Current.Response就表示当前页的Response。

转自:http://blog.csdn.net/flyaim/article/details/5372304

posted @ 2011-08-19 10:44  xgcdd  阅读(11584)  评论(0)    收藏  举报