【发布时间】:2016-06-16 22:41:48
【问题描述】:
我已经在 Stack Overflow(和 google)上搜索过,但找不到解决我问题的具体答案。
我想从页面中读取一些内容。我尝试使用Webclient,但这给了我这个错误:
找不到类型或命名空间名称“WebClient”(您 缺少 using 指令或程序集引用?)
我尝试在谷歌上搜索如何解决这个错误,但没有找到正确的答案(我也尝试过HttpClient,结果相同)。
我如何确保获得他特定页面的内容?
顺便说一句,这就是我现在拥有的:
WebClient client = new WebClient();
// Use google as test page
string downloadString = client.DownloadString("http://www.gooogle.com");
我正在使用 Visual Studio 2015 Community 和 ASP.Net v5
【问题讨论】:
-
您是否将
using System.Net;添加到您的using指令中? -
@S.Akbari 是的,我试过了。然后我得到错误:
A using clause must precede all other elements defined in the namespace except extern alias declarations -
好的。可能你没有把它放在文件的开头!
-
@S.Akbari 我做了(请参阅答案中的评论)
标签: c# asp.net .net webclient dotnet-httpclient