如何在 asp.net mvc 应用程序中为一个控制器操作设置请求超时 [英] How do I set the request timeout for one controller action in an asp.net mvc application
本文介绍了如何在 asp.net mvc 应用程序中为一个控制器操作设置请求超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想增加应用程序中特定控制器操作的请求超时时间.我知道我可以在整个应用程序的 web.config 中执行此操作,但我宁愿仅在此操作中更改它.
I want to increase the request timeout for a specific controller action in my application. I know I can do it in the web.config for the entire application, but I'd rather change it on just this one action.
Web.config 示例:
Web.config example:
<system.web>
<httpRuntime executionTimeout="1000" />
</system.web>
我该怎么做?
推荐答案
您可以在控制器中以编程方式设置:-
You can set this programmatically in the controller:-
HttpContext.Current.Server.ScriptTimeout = 300;
将超时设置为 5 分钟而不是默认的 110 秒(多么奇怪的默认设置?)
Sets the timeout to 5 minutes instead of the default 110 seconds (what an odd default?)
这篇关于如何在 asp.net mvc 应用程序中为一个控制器操作设置请求超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文