码迷,mamicode.com
首页 > Web开发 > 详细

ASP.NET 页面请求超时时间设置 Server.ScriptTimeOut executionTimeout

时间:2016-09-27 19:33:03      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
技术分享
 
 
 
ASP.NET 页面请求超时时间(页面后台程序执行时间)默认值为 110 秒(在 .NET Framework 1.0 版和 1.1 版中,默认值为 90 秒)
即: Server.ScriptTimeout = 110(HttpServerUtility.ScriptTimeout = 110)
        System.Web.Configuration.HttpRuntimeSection().ExecutionTimeout.ToString() = 00:01:50(110 秒)
 
方法一:设置 Server.ScriptTimeout 的值
    注意:设置的值必须大于90,否则不会生效,请求超时值依然是90秒 (网上流传的说法,经验证错误!!!)
               只有当 compilation 元素中的调试属性为 False 时,此超时属性才适用(true:ScriptTimeOut=30000000)。若要避免在调试期间关闭应用程序,请不要将此超时属性设置为较大值。          
//单位秒
Server.ScriptTimeout = 60;
 

方法二:Web.config 配置 httpRuntime executionTimeout (单位秒)

    注意:只有当 compilation 元素中的调试属性为 False 时,此超时属性才适用(true:ScriptTimeOut=30000000)。若要避免在调试期间关闭应用程序,请不要将此超时属性设置为较大值。
               httpRuntime executionTimeout  的设置可修改 Server.ScriptTimeout 的值,使用 ScriptTimeout 属性以编程方式对超时值进行的设置优先于 Web.config 设置。
<system.web>
    <compilation debug="false" targetFramework="4.0" />
    <!-- 设置为600秒 Server.ScriptTimeout = 600 -->
    <httpRuntime executionTimeout="600"/>
</system.web>
  
方法三:设置 HttpRuntimeSection.ExecutionTimeout 的值 (经测试,无效!!!不知如何使用!
System.Web.Configuration.HttpRuntimeSection configSection = new System.Web.Configuration.HttpRuntimeSection();
configSection.ExecutionTimeout = TimeSpan.FromSeconds(100);
 
方法四:IIS配置 修改 脚本超时 值
技术分享技术分享
 
 
技术分享
技术分享
这个未确定 网站→高级设置:
技术分享
技术分享
一样未确定 应用程序池→高级设置:
技术分享
 技术分享
 
注意:如果页面使用了 UpdatePanel,UpdatePanel 内部的请求分以下两种情况:
         ① 设置的超时值 >=90秒,UpdatePanel 内部的请求超时值将变为 90 秒!
         ② 设置的超时值 <90秒,UpdatePanel 内部的请求超时值将变为 所设置的值!
 
下图 Server.ScriptTimeout = 5 秒,点击 UpdatePanel 内部的按钮,Thread.Sleep(20 * 1000) 秒,请求超时,但是页面看不到报错信息!
 而点击UpdatePanel 外部的按钮,则会报如图1的 “请求超时”的错误信息!
技术分享
技术分享
下图 Server.ScriptTimeout = 100 秒,点击 UpdatePanel 内部的按钮,Thread.Sleep(95 * 1000)//停止95秒;    实际上到 90秒就超时了(如下面第二图)
 而点击 UpdatePanel 外部的按钮,Thread.Sleep(95 * 1000)//停止95秒 ,请求成功!
技术分享
技术分享
技术分享
技术分享
 
=======================================================================================================================
全局超时时间
服务器上如果有多个网站,希望统一设置一下超时时间,则需要设置 Machine.config 文件中的 ExecutionTimeout 属性值。
Machine.config 文件位于 %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ 目录中。
<httpRuntime executionTimeout="600" />
 

ASP.NET 页面请求超时时间设置 Server.ScriptTimeOut executionTimeout

标签:

原文地址:http://www.cnblogs.com/575758320-fuyou/p/5913789.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!