韩言福地

只有想不到的,没有办不到的。 - HY Auspicious Place

« ASP.NET文件下载的几种方法msql Order by 根据两列进行分类 »

Server.ScriptTimeout 无效问题

 

  1:  protected void Page_Load(object sender, EventArgs e)

   2:  {
   3:      //Set ScriptTimeout = 5 sec
   4:      Server.ScriptTimeout = 5;
   5:      //Sleep 20 seconds
   6:      System.Threading.Thread.Sleep(20000);
   7:      //Write log
   8:      using (System.IO.StreamWriter sw = 
   9:          new System.IO.StreamWriter("d:\\temp\\bench.log", true))
  10:      {
  11:          sw.WriteLine(
  12:              string.Format("{0:yyyy-MM-dd HH:mm:ss.fff}",
  13:              DateTime.Now
  14:          ));
  15:          sw.Close();
  16:      }
  17:      Response.Write("Done!");
  18:      Response.End();
  19:  }

 

 

发现,將Server.ScriptTimeout设置5秒无法造成Timeout Exception,后来,又改web.config的<httpRuntime> executionTimeout Attribute,仍然无效。

 

1) <compliation debug="true" />时候,ScriptTimeout設定會被忽略。
2) 當Timeout小於1分鐘時,实际上將Delay 5-15秒,也就是說executionTimeout=5,實際上可能要15秒才算Timeout。
3) Server.ScriptTimeout是ASP時代的遺跡,屬於COM Interface,不建議使用,在ASP.NET中要設定Timeout時間請改用web.config 的<httpRuntime> executionTimeout屬性。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Copyright 2007-2010 www.yinrg.com(HY Auspicious Place) . 湘ICP备06007796号.