Robin's Blog

记录 积累 学习 成长

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Last week I had a problem when I tried to export an image from the AGS 9.2 to a pdf file. I got this error: "Sys.WebForms.PageRequestManagerTimeoutException The server request timed out" from the Ajax Extension framework. Its occurred because the export operation was relatively long (something like 2 minutes) and the Ajax Extension Callback framework had a timeout.

How to solve this problem?
To solve this problem we can increase the timeout. You can change the timeout time by adding a new property to the script manager control. This property is called AsyncPostBackTimeOut and it can help us to define the number of seconds before the request will throw a request timeout exception*.

For example if you want that the timeout will take maximum 10 minutes your code should be look like this:

<asp:ScriptManager ID="ScriptManager1" runat="server"

AsyncPostBackTimeOut="600" >

</asp:ScriptManager>     

 

* The default value of the AsyncPostBackTimeOut property is 90 seconds.

Published Monday, April 16, 2007 11:22 PM by Avi Wortzel

-------------

Hi Mark,

If you want to handle this error in client side, you should register to end request event. In your handler check if an error occurred, and handle it (show an alert or put the error in a label).

I hope that this code sample will help you.

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(requestEndHandler );

// This function will handle the end request event
function requestEndHandler(sender, args) {
   if( args.get_error() ){
      document.getElementById("errorMessageLabel").innerText = 
         args.get_error().description;
      args.set_errorHandled(true);
   }
}

</script>
...

<div id="errorMessageLabel"></div>

--------------

Or if you need to change one time in a particular page the timeout, you can add this line inside the page:

AjaxControlToolkit.ToolkitScriptManager ajax = (AjaxControlToolkit.ToolkitScriptManager)this.Page.Master.FindControl("ToolkitScriptManager1");

if(ajax != null)

  ajax.AsyncPostBackTimeout = 600;

posted on 2009-09-23 09:26  Robin99  阅读(1282)  评论(0编辑  收藏  举报