executionTimeout在code

executionTimeout在code

本文介绍了设置ASP.net executionTimeout在code /"刷新"请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一些Excel表格,并将其发送给用户的页面ASP.net。问题是,有时我得到的,因为要求的运行速度比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).

我只是想知道我的选择是,以prevent这一点,不想要一般增加executionTimeout在的web.config

I just wonder what my options are to prevent this, without wanting to generally increase the executionTimeout in web.config?

在PHP中,存在它可以在函数中使用以延长其使用寿命,但我没有看到在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

但你仍然可以在客户端定时的问题出来了,你不能可靠地直接从服务器解决。要解决这个问题,你可以实现一个处理页面(如罗布建议)这回发,直到响应准备。或者你可能想看看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.

这篇关于设置ASP.net executionTimeout在code /"刷新"请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:54