M Z*_*tra 7 .net c# asp.net webclient dotnet-httpclient
我已经在Stack Overflow(和谷歌)上搜索,但找不到解决我问题的具体答案.
我想从页面中读取一些内容.我试过用Webclient,但这给了我这个错误:
找不到类型或命名空间名称'WebClient'(您是否缺少using指令或程序集引用?)
我试图在谷歌搜索如何解决这个错误,但没有找到正确的答案(我也尝试过HttpClient,同样的结果).
如何确保获取其特定页面的内容?
顺便说一下,这就是我现在所拥有的:
WebClient client = new WebClient();
// Use google as test page
string downloadString = client.DownloadString("http://www.gooogle.com");
Run Code Online (Sandbox Code Playgroud)
我正在使用Visual Studio 2015社区和ASP.Net v5
确保您System.dll在项目中有引用。
也可以using System.Net;在计划使用的源代码中包含到usings指令部分,也可以WebClient使用其完全限定的名称,即:
var client = new System.Net.WebClient()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10491 次 |
| 最近记录: |