长时间 ASP.NET 操作上的 IIS 请求超时

编程入门 行业动态 更新时间:2024-10-24 15:16:02
本文介绍了长时间 ASP.NET 操作上的 IIS 请求超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在运行长时间操作时遇到来自 IIS 的请求超时.后台我的 ASP.NET 应用程序正在处理数据,但正在处理的记录数量很大,因此操作需要很长时间.

但是,我认为 IIS 使会话超时.这是 IIS 或 ASP.NET 会话的问题吗?

解决方案

如果您想延长 ASP.NET 脚本允许执行的时间,请增加 :

"此超时仅适用于编译中的调试属性元素为假.因此,如果 debug 属性为 True,则执行不必将此属性设置为大值以避免调试时应用程序关闭."

如果您已经这样做了,但发现您的会话即将到期,请增加ASP.NET HttpSessionState.Timeout 值:

例如:

//将会话超时增加到三十分钟会话.超时 = 30;

这个值也可以在 sessionState 配置元素的 web.config 文件中配置:

<system.web><会话状态模式=InProc"无饼干=真"超时=30"/></system.web></配置>

如果您的脚本需要几分钟来执行并且有很多并发用户,那么请考虑将页面更改为 异步页面.这将提高应用程序的可扩展性.

如果您拥有服务器的管理员访问权限,另一种选择是将此长时间运行的操作视为作为计划任务或 Windows 服务实施的候选者.

I am experiencing a request timeout from IIS when I run a long operation. Behind the scene my ASP.NET application is processing data, but the number of records being processed is large, and thus the operation is taking a long time.

However, I think IIS times out the session. Is this a problem with IIS or ASP.NET session?

解决方案

If you want to extend the amount of time permitted for an ASP.NET script to execute then increase the Server.ScriptTimeout value. The default is 90 seconds for .NET 1.x and 110 seconds for .NET 2.0 and later.

For example:

// Increase script timeout for current page to five minutes Server.ScriptTimeout = 300;

This value can also be configured in your web.config file in the httpRuntime configuration element:

<!-- Increase script timeout to five minutes --> <httpRuntime executionTimeout="300" ... other configuration attributes ... />

Please note according to the MSDN documentation:

"This time-out applies only if the debug attribute in the compilation element is False. Therefore, if the debug attribute is True, you do not have to set this attribute to a large value in order to avoid application shutdown while you are debugging."

If you've already done this but are finding that your session is expiring then increase the ASP.NET HttpSessionState.Timeout value:

For example:

// Increase session timeout to thirty minutes Session.Timeout = 30;

This value can also be configured in your web.config file in the sessionState configuration element:

<configuration> <system.web> <sessionState mode="InProc" cookieless="true" timeout="30" /> </system.web> </configuration>

If your script is taking several minutes to execute and there are many concurrent users then consider changing the page to an Asynchronous Page. This will increase the scalability of your application.

The other alternative, if you have administrator access to the server, is to consider this long running operation as a candidate for implementing as a scheduled task or a windows service.

更多推荐

长时间 ASP.NET 操作上的 IIS 请求超时

本文发布于:2023-11-15 21:21:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598053.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:长时间   操作   NET   ASP   IIS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!