我有一个aspx页面,其中包含在服务器上执行可能需要5分钟或更长时间的代码.所以我需要延长请求超时之前的时间.
将此放在网站的web.config中有什么区别:
<location path="~/MyPage.aspx">
<system.web>
<httpRuntime executionTimeout="600"/>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
并将其放在页面后面的代码中:
protected void Page_Load(object sender, EventArgs e)
{
Page.Server.ScriptTimeout = 600;
}
Run Code Online (Sandbox Code Playgroud) 我将有一个ASP.net页面,它创建一些Excel表格并将它们发送给用户.问题是,有时我会得到Http超时,大概是因为Request运行的时间比executionTimeout长(每个默认值为110秒).
我只是想知道我的选择是什么来防止这种情况,而不想一般增加executionTimeout web.config?
在PHP中,set_time_limit存在可以在函数中使用以延长其寿命,但我在C#/ ASP.net中没有看到类似的东西?
你如何处理ASP.net中的长期运行功能?