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