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?
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.
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).
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.
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.
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With