我如何设置一个控制器操作的请求超时在一个asp.net MVC应用程序 [英] How do I set the request timeout for one controller action in an asp.net mvc application

查看:136
本文介绍了我如何设置一个控制器操作的请求超时在一个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>

我该怎么办呢?谢谢,

How do I do it? Thanks,

凯尔

推荐答案

您可以通过编程控制器设置此: -

You can set this programmatically in the controller:-

HttpContext.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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆