欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

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

转载于:https://www.cnblogs.com/xgcblog/archive/2011/08/19/2145405.html

来自   https://blog.csdn.net/weixin_33734785/article/details/94311004


普通分类: