WebClient could not be found

我的梦境 提交于 2019-12-08 22:14:49

问题


I've already search on Stack Overflow (and google), but can't find the specific answer that solves my problem.

I want to read some content out of a page. I've tried to use Webclient, but that gives me this error:

The type or namespace name 'WebClient' could not be found (ae you missing a using directive or an assembly reference?)

I've tried to search on google how to solve this error, but didn't find a correct answer (I've also tried HttpClient, same result).

How do I make sure that I get the content of his specific page?

Btw, this is what I have right now:

WebClient client = new WebClient();
// Use google as test page
string downloadString = client.DownloadString("http://www.gooogle.com");

And I'm using Visual Studio 2015 Community and ASP.Net v5


回答1:


Make sure you have reference to System.dll in your project.

Also either include using System.Net; to usings directive section of the source code where you're planning to use WebClient or use its fully-qualified name, i.e.:

var client = new System.Net.WebClient()


来源:https://stackoverflow.com/questions/35775000/webclient-could-not-be-found

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