找不到WebClient [英] WebClient could not be found
问题描述
我已经在Stack Overflow(和google)上进行了搜索,但是找不到解决我问题的具体答案。
I've already search on Stack Overflow (and google), but can't find the specific answer that solves my problem.
我想阅读一些内容页面外。我尝试使用 Webclient
,但这给了我这个错误:
I want to read some content out of a page. I've tried to use Webclient
, but that gives me this error:
找不到类型或名称空间名称 WebClient(即您
缺少using指令还是程序集引用?)
The type or namespace name 'WebClient' could not be found (ae you missing a using directive or an assembly reference?)
我尝试在Google上搜索如何解决此错误,但没有找到正确的答案(我也尝试过 HttpClient
,结果相同)。
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");
我正在使用Visual Studio 2015社区和ASP.Net v5
And I'm using Visual Studio 2015 Community and ASP.Net v5
推荐答案
确保在项目中引用了 System.dll
。
Make sure you have reference to System.dll
in your project.
也可以使用System.Net包含;
到您打算在其中的源代码的usings指令部分使用 WebClient
或使用其完全限定的名称,即:
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()
这篇关于找不到WebClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!