【发布时间】:2015-03-23 11:59:00
【问题描述】:
c#代码:
ASCIIEncoding encoding = new ASCIIEncoding();
CookieContainer cook = new CookieContainer();
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create("http://website.com/index.php");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
//myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
//myRequest.AllowAutoRedirect = false;
myRequest.CookieContainer = new CookieContainer();
WebResponse response = myRequest.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
newStream = response.GetResponseStream();
StreamReader reader = new StreamReader(newStream);
Console.WriteLine(reader.ReadToEnd());
index.php
$num= $_POST["num"];
echo $num;
上面的代码以前对我有用,但突然失败了。我尝试了一切
添加CookieContainer(),将Redirection设置为false,使用其他代码进行httprequest。
如果我将AllowAutoRedirect 设置为 false,结果将是:
302 找到
找到 文档已移至此处
但是当我在其他网络托管服务器上尝试这个时,它可以工作。所以我在想它在我的 WHM/cPanel 上?此外,我已经将我的 IP 列入白名单。已经检查 .htaccess 和我的 cpanelb(redirection) 中的选项。
那么有什么想法可能导致这种情况吗?
注意:我已经禁用了云耀斑保护
【问题讨论】:
-
有人吗?这仅发生在一周前。 CloudFlare 是否与此有关?因为我在所有域中都安装了插件