当使用httpwebrequest时,我一直收到脚本说“window.location.reload()”

时间:2011-12-12 17:51:15

标签: c# httpwebrequest

<!--@R--><script>
var k ='c991130d';
var d = new Date();
d.setTime(d.getTime() + (3600*24*365*5*1000));
document.cookie = "p7c=" + k +";  
expires=" + d.toGMTString();
setTimeout(function(){
window.location.reload(); },2000);
</script>
please wait....

当我使用我的代码获取网页时,我会继续获取这些内容,但我可以使用XMLhttp和VB来获取整个页面,这是我的代码:

public static string GetPage(string Url)
{
HttpWebRequest WebRequest = (HttpWebRequest)HttpWebRequest.Create(Url);
WebRequest.Timeout = 5000;
WebRequest.AllowAutoRedirect = true;
WebRequest.Headers.Set("Pragma", "no-cache");

try
{
   using (HttpWebResponse response = (HttpWebResponse)WebRequest.GetResponse())
   {
      using (Stream stream = response.GetResponseStream())
      {
        using (StreamReader sr = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
           { return sr.ReadToEnd(); }
      }
   }
}
catch (Exception ex){ return "%ERROR%" + ex.Message; }
}    

0 个答案:

没有答案