[转]Working with the Web ADF timeout showLapseAlert 9.3 与 9.2

Working with the Web ADF timeout
Rex Hansen provided this tip on working with the Web ADF timeout
One of the timeouts that you need to be aware of when building Web applications is the Web ADF timeout. The Web ADF timeout provides a single client-side solution for handling an ASP.NET session timeout before a callback or postback can generate an error on the server.

The Web ADF timeout helps provide the user with an understandable error message if the ASP.NET session times out and the application cannot return any more information. When the Web ADF timeout is reached in a Web ADF application, the following error message will tell you that you need to restart the session.

 

It's a good practice to keep the Web ADF timeout the same length of time as the ASP.NET session timeout. To control the Web ADF timeout, use the JavaScript variable maximumLapseTime, which is included in the display_common.js file. The timeout value is in minutes. For example, to set the Web ADF timeout to 20 minutes, you would add the following to the form that contains your Web ADF controls:

<script language="javascript" type="text/javascript">
  var maximumLapseTime = 20;
</script>

Note: The above code is for the 9.2 Web ADF. At 9.3 you must use the fully qualified name, for example ESRI.ADF.System.maximumLapseTime = 20.

If you have added a programmatic means of keeping the ASP.NET session alive, you can avoid reaching the Web ADF timeout by setting maximumLapseTime = Infinity. Be aware that if the ASP.NET session does time out, clients may not receive the user-friendly error message they would see if the Web ADF timeout were in effect.

You can learn about the maximumLapseTime variable used above, and the other types of timeouts in Timeout settings in the Web ADF and ASP.NET.

Published Tuesday, September 04, 2007 4:03 PM by sterlingdq
Filed under: .NET, JavaScript
Comment Notification
If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments
# re: Working with the Web ADF timeout
This error has bugged me for a long time. I understand what happens when a session times out, but why do you force the user to close the browser and reopen it to continue working with the applicaiton. Why not a message saying "your session has timed out and will be reset" When you hit OK, The application does a page refresh and you are back to the initial state. I would think this could be done and is much more user-friendly.
Tuesday, September 11, 2007 3:27 PM by Whitey
# re: Working with the Web ADF timeout
Dear sterlingdq or other folks, Can I manually change display_common.js file? Because other than reset the time-out value, I am also thinking of changing the alert messages. I tried to change this file manually, but it doesnot work? it is strange to me? Like I change the time out to 2 minutes manually, but the application still use 10 minutes. Thanks and Regards, Xijiang Sun ------------- sunx@saic.com
Tuesday, September 11, 2007 10:07 PM by xijiang sun
# re: Working with the Web ADF timeout
it's very good!
Wednesday, September 12, 2007 12:16 AM by David
# re: Working with the Web ADF timeout
Hi folks, There appear to be two issues here: using Web ADF JavaScript file content and overriding the message and action that occurs when reaching the timeout. If you make a change to the display_common.js, you'll also need to change the UseDefaultWebResources property to false, so the file on disk will used. There are a few other optios to consider here. See the discussion under the “Web ADF JavaScript libraries” heading near the bottom of this page: http://edndoc.esri.com/arcobjects/9.2/NET_Server_Doc/developer/ADF/control_overview.htm To change the message returned after the timeout is reached “override” the showLapseAlert() JavaScript function. “Override” in this sense means define the showLapseAlert() JavaScript function after the function in display_common.js. Here’s an example - include this at the end of the aspx page:
  var maximumLapseTime = 1;
 
  function showLapseAlert() {
    alert("Application has timed out.  Reloading.");
    window.location.reload();
  }
Note that this also triggers a page reload via JavaScript. Hope this helps, -Rex
Thursday, September 20, 2007 11:18 AM by Rex Hansen
# re: Working with the Web ADF timeout
I experimented with this using the template application. I created the app through the Manager. I pasted the script into the form after the reference to WebMapApp.js like so: I tested tools and tasks with 2 different settings. First with the session timeout in the web.config at default and ADF timeout at 1 minute, second where session timeout and ADF timeout were synchronized at 1 minute. After 1 minute elapsed, use of several of the tools (Zoom In, Zoom Out, Pan) resulted in the alert like the one show above. Other tools and tasks were not affected by the ADF timeout. Identify, for example just hangs when the timeouts are in sync - it seems to reset the ADF timeout when they are not. More problematic is the measure tool. Even when timeouts are in sync, the measure tool functions but returns erroneous values. I tested another application that has a custom tool. After 1 minute, the use of my custom tool was prevented by the ADF timeout, which is great. -Dave
Wednesday, October 24, 2007 9:18 AM by Dave Fullerton
# re: Working with the Web ADF timeout
Does this still work in 9.3?  I am having issues, it won't run my overridden showLapseAlert function.

Tuesday, November 25, 2008 10:01 AM by sfisher
# re: Working with the Web ADF timeout
Just figured it out, you need to override the ESRI.ADF.System.showLapseAlert function now at 9.3.

ESRI.ADF.System.showLapseAlert

 = function()

 {

   alert("Application has timed out. Reloading.");

   window.location.reload();

 }

Yet another small javascript change from 9.2 to 9.3 just to make things difficult.  Not sure why this stuff could not be kept backwards compatiable.

Tuesday, November 25, 2008 10:08 AM by sfisher
还有一点要注意,因为是overridden,故 var ESRI.ADF.System.maximumLapseTime = 20. 是错误的。前面var 应去掉。因为是 已存在的全局变量。

posted @ 2009-12-11 20:00  AooYu  阅读(370)  评论(0编辑  收藏  举报