Friday, 15 April 2011

ASP.NET AJAX: Page Method Timeout

Hi,

While working with PageMethods I came to know that there is no default timeout for PageMethods and in one of my project timeout was required to set for my PageMethods calls. I found a way to do this and would like to share it with you.

You can add a timeout to your PageMethod calls using javascript in one simple line as:

PageMethods._staticInstance._timeout = 3000; // 3000 is in milliseconds

Note: 
  • Timeout value is in milliseconds.
  • On timeout, callback method attached to OnFailure event is fired .i.e. If you call your PageMethod as PageMethods.HelloWorld(onSuccess, onFailure); then on timeout method onFailure will be called.

No comments:

Post a Comment