在代码/" refresh& quot;中设置ASP.net执行超时.要求 [英] Set ASP.net executionTimeout in code / "refresh" request
问题描述
我将拥有一个ASP.net页面,该页面创建一些Excel工作表并将其发送给用户.问题是,有时我会收到Http超时,大概是因为请求运行的时间比executionTimeout(默认情况下为110秒)更长.
I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default).
我只是想知道我有什么选择来防止这种情况,而又不想总体上增加 web.config
中的executionTimeout?
I just wonder what my options are to prevent this, without wanting to generally increase the executionTimeout in web.config
?
在PHP中, set_time_limit
存在,可以在函数中使用它来延长其寿命,但是我在C#/ASP.net中没有看到类似的东西?
In PHP, set_time_limit
exists which can be used in a function to extend its life, but I did not see anything like that in C#/ASP.net?
如何处理ASP.net中长期运行的功能?
How do you handle long-running functions in ASP.net?
推荐答案
如果您想增加此请求的执行超时时间,可以设置
If you want to increase the execution timeout for this one request you can set
HttpContext.Current.Server.ScriptTimeout
但是您仍然可能遇到客户端超时的问题,您无法直接从服务器可靠地解决该问题.为了解决这个问题,您可以实现一个处理"页面(如Rob所建议的),该页面回发直到响应准备就绪.或者,您可能希望研究AJAX来做类似的事情.
But you still may have the problem of the client timing out which you can't reliably solve directly from the server. To get around that you could implement a "processing" page (like Rob suggests) that posts back until the response is ready. Or you might want to look into AJAX to do something similar.
这篇关于在代码/" refresh& quot;中设置ASP.net执行超时.要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!