ASP.NET can not find HttpUtility

我与影子孤独终老i 提交于 2019-12-08 22:11:31

问题


The name 'HttpUtility' does not exist in the current context.

I'm a bit stuck here. I have using System.Web at the top of my file, which has no error, and System.Web is listed in my references. I tried double-clicking the reference, finding the UrlEncode method in the object browser, and literally drag-and-dropping the method into my code, and it still can't find HttpUtility. What am I missing?

Here is the code, boiled down:

using System.Web

string path = "path/to/file";
path = HttpUtility.UrlEncode(path);

Fully qualifying HttpUtility doesn't help either. It doesn't even show up in the auto-complete list. Only "AspNetHostingPermission" shows up.


回答1:


Look to me like you have another library in your solutions and that's where you are trying to access the HttpUtility. If that's correct, you need to add a reference to System.Web dll in your library.

Let me know if that was the case.



来源:https://stackoverflow.com/questions/9183435/asp-net-can-not-find-httputility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!