Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET can not find HttpUtility

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.

like image 294
directedition Avatar asked Feb 07 '12 20:02

directedition


1 Answers

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.

like image 54
Sebastian Siek Avatar answered Oct 21 '22 15:10

Sebastian Siek