我正在使用以下命令执行 Web 请求:
// create http request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
// set user agent
req.UserAgent = "Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0";
req.AllowAutoRedirect = true;
req.MaximumAutomaticRedirections = 3;
// retrieve response
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
HttpStatusCode stc = rep.StatusCode;
在某些 URL(但不是全部)上,状态返回 OK,内容长度为 -1,但如果我直接使用 Firefox,它会呈现。
我需要提供给 C# 的设置吗?示例链接http://www.cbsstore.com/detail.php?p=382214&ecid=5511&pa=CSE-FGL&CAWELAID=1599172025