Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase ASP.Net timeout on a per page level

Is it possible to increase the timeout for a single ASP.net 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?

like image 216
ChrisCa Avatar asked Jun 24 '10 09:06

ChrisCa


People also ask

How can increase session timeout in ASP.NET MVC 5?

Open the web. config file, then increase the value in minutes by using the time out attribute of SessionState element. By default, the session timeout value is 20 minutes. Also in your case if you are using forms authentication, please check the timeout value.

What is SessionState timeout in web config?

The Timeout property can be set in the Web. config file for an application using the timeout attribute of the sessionState configuration element, or you can set the Timeout property value directly using application code. The Timeout property cannot be set to a value greater than 525,600 minutes (1 year).


3 Answers

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.

like image 112
Mark Bell Avatar answered Oct 28 '22 02:10

Mark Bell


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">
    <system.web>
      <httpRuntime executionTimeout="600"/>      
    </system.web>    
  </location>

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

  <location path="~/MyPage.aspx">
    <system.web>
      <httpRuntime executionTimeout="6000" maxRequestLength="204800" />      
    </system.web>    
    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="209715200" />
        </requestFiltering>
      </security>
    </system.webServer>
  </location>

Hope this helps.

like image 20
Krishnan Avatar answered Oct 28 '22 01:10

Krishnan


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

using (var connection = new SqlConnection(connectionString)) 
{
  connection.Open();
  SqlCommand command = new SqlCommand(queryString, connection);
  // Setting command timeout to 100 seconds
  command.CommandTimeout = 100;
  command.ExecuteNonQuery();
}
like image 1
Max Alexander Hanna Avatar answered Oct 28 '22 02:10

Max Alexander Hanna