System.dll中出现未处理的“System.Net.WebException”类型异常附加信息:请求已中止:操作已超时。
由using (System.Net.WebResponse resp = req.GetResponse())
public string HttpGet(string URI)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
req.Proxy = new System.Net.WebProxy(WebRequest.DefaultWebProxy.GetProxy(new Uri("http://google.com")), false); //true means no proxy
using (System.Net.WebResponse resp = req.GetResponse())
{
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
string value = sr.ReadToEnd().Trim();
return value;
}
}
req.Timeout = 9999999;
或其他任何内容,但它仍会产生相同的错误。导致此超时的原因是什么?我该怎么办呢?
正在调用的文件:
include($_SERVER['DOCUMENT_ROOT'] . '/PHP Files/Computing Project - Website/ICTeacher/GeneralFunctions/functions.php');
connect_to_database();
$query = $_GET["query"];
$password = $_GET["password"];
if ($password == "X") {
if (strpos($query, 'SELECT') !== false) {
$query_result = mysql_query($query);
if (mysql_num_rows($query_result) != 0) {
for ($x=0; $x <= mysql_num_rows($query_result); $x++) {
echo mysql_result($query_result, $x);
}
}
}
}