无法识别System.Web.HttpContext [英] System.Web.HttpContext not recognized

查看:118
本文介绍了无法识别System.Web.HttpContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有C#Web应用程序的ASP.NET.我创建的类之一需要使用HttpContext.

I have a ASP.NET with C# web application. One of the classes I created needs to use HttpContext.

根据 http://msdn.microsoft.com/zh-CN/library/system.web.httpcontext(v=vs.90).aspx ,HttpContext存在于.NET 3.5(这是我已安装的版本)的System.Web命名空间中.

According to http://msdn.microsoft.com/en-us/library/system.web.httpcontext(v=vs.90).aspx, HttpContext exists in the System.Web namespace in .NET 3.5 (which is the version I have installed).

但是,当我写HttpContext时.->我看不到自动完成功能.这就是告诉我HttpContext无法识别的原因.

However, when I write HttpContext. --> I don't see autocomplete. Which is what tells me that HttpContext is not recognized.

我做了作业,并寻找了常用的解决方案:1.我添加了System.Web参考(通过右键单击参考"->选择".NET"选项卡和特定参考).2.我还确保将以下行包含在类中:using System.Web;

I did my homework and looked for usual solutions: 1. I added System.Web reference (by right clicking References -> choosing .NET tab and the particular reference). 2. I also made sure to include this line in the class: using System.Web;

请告诉我我还能做什么.如果一切顺利,当我写HttpContext时.-我应该看到一个下拉列表,并能够从几个属性/元素中选择当前".我是C#和Visual Studio(2008)的新手,但我认为Autocomplete不能很好地运行,这很好地表明了缺乏参考/命名空间/加载错误/其他任何方面.

Please tell me what else can I do. If all goes well, when I write HttpContext. - I am supposed to see a drop down list and be able to choose "Current" from there amongst several attributes/elements. I am new with C# and Visual Studio (2008) but I think Autocomplete not working well is a good indicator of a lacking reference/namespace/load errors/whatever else.

推荐答案

当您要实例化 HttpContext 类时,很少使用构造函数.我始终使用静态属性 HttpContext.Current ,它是所有ASP.Net应用程序使用的当前实例.

The constructor is rarely used when you want to instantiate the HttpContext class. I always use the static property HttpContext.Current which is the current instance used by all the ASP.Net application.

要使用它,请确保已添加对System.Web.dll程序集的引用并导入 System.Web 名称空间

For using it make sure you already add reference to the System.Web.dll assembly and import the System.Web namespace

这篇关于无法识别System.Web.HttpContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆