0
当我在特定的URL上运行HTTPWebRequest时,它返回503(服务器不可用)。这里是我的代码:C#Web请求/服务器不可用错误/ HTTP头
webClient.Headers[HttpRequestHeader.UserAgent] = _userAgent;
webClient.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";
webClient.Headers[HttpRequestHeader.Accept] = "Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*";
webClient.Headers[HttpRequestHeader.Cookie] = "searchState=WA";
byte[] firstResponse = webClient.DownloadData(URL);
下面是当我要求在IE页面什么是发送到浏览器(根据小提琴手):
GET http://www.[url].com/[url] HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0E)
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Host: www.[url].com
Cookie: searchState=WA
还有什么我需要添加到我的码?非常感谢。
编辑:这里是响应头:
HTTP/1.0 200 OK
Date: Fri, 21 Jan 2011 04:02:33 GMT
Server: Apache-Coyote/1.1
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=UTF-8
Set-Cookie: JSESSIONID=39EFAAA14B9C6E0384631007966B7CB8; Path=/
Set-Cookie: searchState=WA; Expires=Sun, 20-Feb-2011 04:02:33 GMT; Path=/
Set-Cookie: search_tab=R; Path=/
X-Cache: MISS from 200.157.247.7
Proxy-Connection: close
Content-Length: 26987
当我在IE中打开它时,页面加载就好了。 – alpheus 2011-01-21 04:34:37