尝试了太多的自动重定向(甚至 CookieContainer 失败)


Too many automatic redirections were attempted (even CookieContainer fail)

c# code:

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());

索引.php

$num= $_POST["num"]; 
echo $num;

上面的代码以前对我有用,但突然失败了。我什么都试过了添加CookieContainer() ,将重定向设置为 false,使用 httprequest 的其他代码。

如果我AllowAutoRedirect设置为 false,结果将是:


302 找到

发现文档已移至此处


但是当我尝试在其他网络托管服务器上执行此操作时,它可以工作。所以我在我的 WHM/cPanel 上想它?我也已经将我的IP列入白名单。已经检查了 .htaccess 和我的 cpanelb(重定向)中的选项。

那么任何想法可能导致这种情况吗?

注意:我已经禁用了云耀斑保护

已经找到了解决方案。当他们更新我的 WHM 并在 ModSecurity 工具中添加了一些我不知道的规则时。我只是禁用它,一切都恢复正常:)