那么这个问题几乎可以解释它。我知道在String.equals期间代码非常脏,但我只想看看我是否理解标题响应。很明显,我没有,因为我在我的浏览器中观看,当添加新的问题时,我的程序从不输出“是的,它改变了”为什么?为什么此代码无法检测页面更新?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;
using System.Net;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Uri myUri = new Uri("http://stackoverflow.com/questions?sort=newest");
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
string org = myHttpWebResponse.Headers.GetValues("Date")[0];
string newone = "";
while (true) //STRICTING FOR TESTING. THIS WOULD BE A Dos ATTACK AS IT NEVER HAS A DELAY BETWEEN REQUESTS.
{
myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
newone = myHttpWebResponse.Headers.GetValues("Date")[0];
if (!newone.Equals(org))
break;
}
Console.WriteLine("Yep it changed");
Console.ReadLine();
}
}
}
不要降低我的愚蠢问题。我试图让MODS删除它。 – FrostyFire