在 C# 中的 System.Web 中找不到 HttpServerUtility 类
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几点:
System.Web
程序集的引用HttpServerUtility
,而不是HttpServerUtility
)UrlDecode
,而不是URLDecode
)获取实例可能是最难的部分,除非您使用 ASP.NET - 它没有任何公共构造函数或静态属性来获取实例。通常您会使用
HttpContext.Server
。另一种方法是使用
HttpUtility.UrlDecode
,这是一个静态方法。 (同样,您需要引用
System.Web
。)A few points:
System.Web
assemblyHttpServerUtility
, notHttpServerUtuility
)UrlDecode
, notURLDecode
)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 useHttpUtility.UrlDecode
, which is a static method. (Again, you'll need a reference toSystem.Web
.)添加对 System.Web 程序集的引用。
Add a reference to the System.Web assembly.
必须将程序集添加到我的 Web api
Had to add assemblies to my web api