我用System.Net.WebClient的DownloadData()方法下载网页内容,一般的网页都没有问题(如http://www.126.com等),
可是这个网页报错:http://www.gtja-allianz.com“远程服务器返回错误: (500) 内部服务器错误。"
System.InvalidOperationException {System.Net.WebException}找了很长时间都不知道什么原因!请大家帮忙!
主要代码如下:
try
{
WebClient MyWebClient = new WebClient();
MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于对向Internet资源的请求进行身份验证的网络凭据。
Byte[] pageData = MyWebClient.DownloadData("http://www.gtja-allianz.com");//从指定网站下载数据
....
}
catch (Exception ep)
{
return;
}
可是这个网页报错:http://www.gtja-allianz.com“远程服务器返回错误: (500) 内部服务器错误。"
System.InvalidOperationException {System.Net.WebException}找了很长时间都不知道什么原因!请大家帮忙!
主要代码如下:
try
{
WebClient MyWebClient = new WebClient();
MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于对向Internet资源的请求进行身份验证的网络凭据。
Byte[] pageData = MyWebClient.DownloadData("http://www.gtja-allianz.com");//从指定网站下载数据
....
}
catch (Exception ep)
{
return;
}
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/msword, application/vnd.ms-powerpoint, application/x-shockwave-flash, application/x-silverlight-2-b2, application/x-silverlight, application/vnd.ms-excel, */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022)
Host: www.gtja-allianz.com
Proxy-Connection: Keep-Alive
看看请求的User-Agent