我试过的代码:
string contents = string.Empty;
using (var wc = new System.Net.WebClient())
{
contents = wc.DownloadString("http://www.bizjournals.com/albany/blog/health-care/2015/10/what-this-local-bank-did-to-control-health-care.html");
}
但是它的投掷错误
远程服务器返回错误:(416)请求的范围不是 可满足的
答案 0 :(得分:1)
如果您的客户端未发送User-Agent标头,则某些Web服务器可能会返回416。尝试添加标题,如下所示:
wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705");