O'Reilly logo

Professional ASP.NET 3.5 AJAX by Matt Gibbs, Dan Wahlin, Bill Evjen, Dave Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9.3. Managing Web Requests

The WebRequest object works with a static WebRequestManager JavaScript object to coordinate the behavior of the ASP.NET AJAX networking stack. Even though you may not reference the object directly, the individual WebRequest objects that you create work with it to execute requests using the XMLHttpRequest object. In fact, the WebRequestManager does not know the specifics of the XMLHttpRequest object. Instead, it works with the WebRequestExecutor, an object that abstracts some of the underlying browser-specific details. These JavaScript objects are part of the Microsoft AJAX Library. Later in this chapter, you learn how to use a WebRequestExecutor tailored for working with XML data instead of JSON.

9.3.1. Default Timeout

Listing 9-10 (TimedSleep.aspx) modifies the Sleep.aspx page to return the amount of time that has passed during request processing instead of specific form variables. The sleep of two seconds simulates a server-side process that may require two seconds to execute.

Example 9-10. TimedSleep.aspx
<%@ Page Language="C#" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    DateTime start = DateTime.Now;
    System.Threading.Thread.Sleep(2000);
    DateTime finish = DateTime.Now;
    Response.Write(finish - start);
}
</script>

Listing 9-11 (CallTimedSleep.aspx) does not specify a timeout, so it gets the default value of 0, which indicates that the WebRequest should be allowed to wait indefinitely for a response from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required