c# - HTTP 响应错误 503

标签 c# http httpwebrequest cloudflare http-status-code-503

我正在尝试从 CloudFlare 托管的网站下载网页数据。它使用 HTTPS 并在进入页面之前获取连接 ID。

我试图在 WebRequest 和 WebResponse 中获取 id,但出现以下错误:

An unhandled exception of type 'System.Net.WebException' occurred in System.dll Additional information: The remote server returned an error: (503) Server Unavailable.

我尝试从 Fiddler 发出请求,这是响应:

HTTP/1.1 503 Service Temporarily Unavailable
Date: Tue, 12 May 2015 13:38:17 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d57a7d982035dad7ebafe63444d125e451431437897; expires=Wed, 11-May-16 13:38:17 GMT; path=/; domain=.hornystress.me; HttpOnly
X-Frame-Options: SAMEORIGIN
Refresh: 8;URL=/cdn-cgi/l/chk_jschl?pass=1431437901.815-Ym1g5qTodK
Cache-Control: no-cache
Server: cloudflare-nginx
CF-RAY: 1e5685ed559606ee-LHR

这是我的代码:

public static string GetCookie(string link)
{
    WebRequest request = WebRequest.Create("https://hornystress.me");
    request.Proxy = WebProxy.GetDefaultProxy();
    request.Timeout *= 100;
    WebResponse response = request.GetResponse();
    return response.Headers.Get("Set-Cookie");
}

最佳答案

无论您在做什么,都可能看起来像是对网站的攻击,并且它正在触发安全功能。您可能希望网站所有者将发出调用的 IP 列入白名单。

关于c# - HTTP 响应错误 503,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30192746/

相关文章:

c# - 从 URL 字符串中删除父路径的最快、最干净的方法是什么?

c# - 已经有一个打开的 DataReader 与此连接关联,必须先将其关闭

java - 在 IBM Domino 中创建重定向的 HTTP 请求的方法

c# httpwebrequest getResponse() 卡住并挂起我的程序

c# - 从unity c#调用java方法

c# - 带有 EF6 和 dotConnect for oracle 的 aspnetcore 2.0

http - Flutter http请求上传mp3文件

java - 如何在不离开页面的情况下从 servlet 返回一个字符串?

c# - 对于许多并发的 http 请求,是否有一个好的线程模型?

asp.net - 通过 HTTPS 的 HttpWebRequest,NTLM 不工作