gpt4 book ai didi

c# - 在 C# 的 System.Web 中找不到 HttpServerUtility 类

转载 作者:太空狗 更新时间:2023-10-29 19:55:25 25 4
gpt4 key购买 nike

我正在尝试调用 HttpServerUtuility.URLDecode function在 C# 中使用 Visual Studio 2005,但找不到。我正在 正确使用 System.Web,但该类似乎不存在。我需要为我的项目添加某种引用吗?

最佳答案

几点:

  • 您需要对 System.Web 程序集的引用
  • 您需要正确获取类名(HttpServerUtility,而不是HttpServerUtuility)
  • 您需要正确获取方法名称(UrlDecode,而不是URLDecode)
  • 你需要一个类的实例,因为它是一个实例方法

获取实例可能是最困难的部分,除非您使用的是 ASP.NET - 它没有任何公共(public)构造函数或静态属性来获取实例。通常你会使用 HttpContext.Server .另一种方法是使用 HttpUtility.UrlDecode一个静态方法。 (同样,您需要引用 System.Web。)

关于c# - 在 C# 的 System.Web 中找不到 HttpServerUtility 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1368596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com