Increase ASP.Net timeout on a per page level

Is it possible to increase the timeout for a single page. I know it is possible at the server level, but is it possible at thepage level?

I need this for a single report page that takes 2-3 minutes to load

any ideas?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think what you’re looking for is ScriptTimeout. You can set this in-page like this:

Page.Server.ScriptTimeout = 60;

The timeout value is in seconds.

Also, be aware of the fact that if you are running in debug mode, this gets ignored and the timeout is set to the maximum; I don’t think that’s an issue for you anyway though, as you’re increasing the timeout, not decreasing it.

Method 2

As per this page, and I could verify too, another good way to achieve this is to add this to your config’s configSection:

  <location path="~/MyPage.aspx">
      <httpRuntime executionTimeout="600"/>      

You could then also add other attributes like maxRequestLength="204800" or other sections, like:

  <location path="~/MyPage.aspx">
      <httpRuntime executionTimeout="6000" maxRequestLength="204800" />      
          <requestLimits maxAllowedContentLength="209715200" />

Hope this helps.

Method 3

Ive found my problem was resolved by increasing the SQL timeout,
using command.CommandTimeout = 100;

using (var connection = new SqlConnection(connectionString)) 
  SqlCommand command = new SqlCommand(queryString, connection);
  // Setting command timeout to 100 seconds
  command.CommandTimeout = 100;

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x