IIS Request Timeout on long ASP.NET operation(长时间 ASP.NET 操作的 IIS 请求超时)
问题描述
我在运行长时间操作时遇到来自 IIS 的请求超时.在后台我的 ASP.NET 应用程序正在处理数据,但是正在处理的记录数量很大,因此操作需要很长时间.
但是,我认为 IIS 会使会话超时.这是 IIS 或 ASP.NET 会话的问题吗?
如果您想延长 ASP.NET 脚本允许执行的时间,请增加 :
<块引用>"此超时仅适用于编译中的调试属性元素为假.因此,如果调试属性为 True,则执行不必将此属性设置为较大的值以避免调试时关闭应用程序."
如果您已经完成此操作,但发现您的会话即将到期,请增加ASP.NET HttpSessionState.Timeout 值:
例如:
//将会话超时增加到三十分钟会话超时 = 30;也可以在 web.config 文件的 sessionState 配置元素中配置此值:
<配置><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 请求超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:长时间 ASP.NET 操作的 IIS 请求超时
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
