There are three timeouts to consider when using a Web ADF application: Web ADF timeout (client-tier), ASP.NET session timeout (Web-tier), data source timeout (server-tier). The relationships between the different timeout values and where they apply is important to understand.
The Web ADF timeout is only used by the browser. The ASP.NET session is not aware of the client timeout, however both the client and Web-tier timeouts are designed to work together. The Web ADF timeout gives you the ability to use browser logic to provide the end-user with information about timeout details, without requiring an additional request to the Web server. This is important in an asynchronous communication environment (such as AJAX-enabled Web ADF controls) where you want to intercept a callback to a Web application session that no longer exists. In general, the Web ADF timeout is designed for the end user while the ASP.NET session timeout is necessary from a Web application perspective to dispose of resources. With this in mind, the Web ADF timeout can be the same or less than the ASP.NET session timeout. In most cases, they should be the same (they are by default).
The data source timeout is usually necessary to control erroneous requests to services to make sure system resources are available and utilized appropriately. Timeout values are relative and depend on service requirements. Since most requests to services in the Web ADF are stateless, ASP.NET session timeout does not play a part. However, if a connection to a service is persistent across requests, the relationship between ASP.NET session timeouts and data source timeouts may need to be considered. In the case of ArcGIS Server local connections to non-pooled services, server context can be created once at the beginning of a session and maintained (persisted) for the duration of the session. If the "maximum use" timeout on the ArcGIS Server service is less than the session timeout, it is possible that server context will need to be recreated.
1) The Web ADF timeout is set during initial page load. If a page contains an ADF control, a line of JavaScript is injected into the page to set the ESRI.ADF.System.maximumLapseTime variable. By default, the value of this variable is set to the Web application session timeout value in minutes. For example, if the Web application session timeout is 20 minutes, the following line of JavaScript will be added to the page at runtime:
ESRI.ADF.System.maximumLapseTime = 20;
In order to change this value for a Web ADF application, you need to change the ESRI.ADF.System.maximumLapseTime variable after form contents are loaded. In the Web page add the following script tag after the form that contains Web ADF controls:
<script language="javascript" type= "text/javascript"> ESRI.ADF.System.maximumLapseTime = 10; </script>
To disable the Web ADF timeout, set the ESRI.ADF.System.maximumLapseTime variable to Infinity:
<script language="javascript" type="text/javascript"> ESRI.ADF.System.maximumLapseTime = Infinity; </script>
To change the message returned after the timeout is reached "override" the
ESRI.ADF.System.showLapseAlert() JavaScript function. "Override" in this sense
means define the ESRI.ADF.System.showLapseAlert() JavaScript function is
created and set upon initial page load. For example, include this
after the form tag in aspx page:
<script language="javascript"
type= "text/javascript"> ESRI.ADF.System.showLapseAlert
= function()
{
alert("Application has timed out. Reloading.");
window.location.reload();
}
</script>
Note that this also triggers a page reload via JavaScript.
To check if the Web ADF timeout has elapsed, call the ESRI.ADF.System.checkSessionExpired function. If it returns true, the timeout has elapsed. Differences in browser behavior may require you to call the function or check it as a property.
if(ESRI.ADF.System.checkSessionExpired &&
ESRI.ADF.System.checkSessionExpired()) { //do something or nothing; }
2) The ASP.NET session timeout can be set in the web.config file. By default,
it is set to 20 minutes. To change the timeout for a Web application, add the
following to your web.config, within <system.web>:
<sessionState timeout="10"/>
3) A data source timeout is managed by the data source provider. For example, ArcIMS administrators have the ability to change the time allotted for a spatial server to process a request. ArcGIS Server administrators can change the usage time allotted for an individual service. Administration documentation for specific data sources may provide additional details on timeout management at this level.