您可以使用System.Net.WebClient类来访问URL.
using (WebClient client = new WebClient())
{
client.Headers["User-Agent"] = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0)" +
" (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
// Download data.
byte[] arr = client.DownloadData("http://www.yourserver.com/"); // url for .ashx file
// Write values.
Console.WriteLine("--- WebClient result ---");
Console.WriteLine(arr.Length);
}
Run Code Online (Sandbox Code Playgroud)
在这里,您可以找到MSDN文档.
| 归档时间: |
|
| 查看次数: |
1197 次 |
| 最近记录: |