Friday, August 5, 2011

understanding AJAX timeout settings for .Net application

Why bother? If you use the default Ajax timeout setting, which is 110 seconds (or 90 seconds for .Net framework 1.0/1.1), users may get the timeout error, especially when they are using the web application with a slow network connection.

In order to set the AJAX timeout settings, you would need to check three things in your code

1) add below code in the web.config file - for example to set it to 10 minutes (600 seconds).

- <httpRuntime executionTimeout="600" maxRequestLength="40960"/>

2) this above executionTimeout setting only applies if you set the "debug" attribute in the <Compilation> tag to "False" in the web.config. Here is the reference

- http://msdn.microsoft.com/en-us/library/e1f13641.aspx

3) you would also need to set AsyncPostBackTimeout in the aspx page (or the site.master page) to match with the setting in the web.config file.

- <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="600">
...
</asp:ScriptManager>

This is one type of hidden bugs, if your developer's or QC's network speed is faster than your end-users. :)

Of course, you would also need to watch out the timeout settings for your website and web services, if any.