How do I set the request timeout for one controller action in an mvc application


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 example:

  <httpRuntime executionTimeout="1000" />

How do I do it? Thanks,



You can set this programmatically in the controller:-

HttpContext.Server.ScriptTimeout = 300;

Sets the timeout to 5 minutes instead of the default 110 seconds (what an odd default?)

<location path="ControllerName/ActionName">
    <httpRuntime executionTimeout="1000"/>

Probably it is better to set such values in web.config instead of controller. Hardcoding of configurable options is considered harmful.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s