找不到的System.Web在C#HttpServerUtility类 [英] Can't find HttpServerUtility class in System.Web in C#
问题描述
我想打电话给 HttpServerUtuility.URLDecode功能在C#中使用Visual Studio 2005,但它不能被发现。我使用的System.Web
正常,但类似乎并不存在。 ?我是否需要某种形式的引用添加到我的项目
I'm trying to call the HttpServerUtuility.URLDecode function in C# using Visual Studio 2005, but it can't be found. I'm using System.Web
properly, but the class doesn't seem to be there. Do I need to add some sort of reference to my project?
推荐答案
的几点:
- 您需要将
的System.Web
程序集的引用 - 您需要得到的类名右(
HttpServerUtility
,而不是HttpServerUtuility
) - 您需要获得方法姓名权(
UrlDecode
,而不是URLDecode
) - 你所需要的类的实例,因为它是一个实例方法
- You need a reference to the
System.Web
assembly - You need to get the class name right (
HttpServerUtility
, notHttpServerUtuility
) - You need to get the method name right (
UrlDecode
, notURLDecode
) - You need an instance of the class, as it's an instance method
获取一个实例很可能是最难的部分,除非你'再在ASP.NET - 它不具有任何公共构造函数或静态属性获取实例。通常你会使用 HttpContext.Server
。另一种方法是使用 HttpUtility.UrlDecode
,该是的静态方法。 (同样,你需要参考的System.Web
)
Getting an instance is likely to be the hardest part, unless you're in ASP.NET - it doesn't have any public constructors or a static property to fetch an instance. Usually you'd use HttpContext.Server
. An alternative is to use HttpUtility.UrlDecode
, which is a static method. (Again, you'll need a reference to System.Web
.)
这篇关于找不到的System.Web在C#HttpServerUtility类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!