Wednesday, April 25, 2007

ASP.NET Asynchronous Model

Did you know that in ASP.NET 2.0 it is possible to use the power of asynchronous pages just by including an Async="true" attribute in the page's @ Page directive, like so:
<%@ Page Async="true" ...
Jeff Prosise's in his article explains that this tells ASP.NET to implement IHttpAsyncHandler in the page. Next, you should call the new Page.AddOnPreRenderCompleteAsync method early in the page's lifetime (for example, in Page_Load) to register a Begin method and an End method, as shown in the following code:
AddOnPreRenderCompleteAsync (new BeginEventHandler(MyBeginMethod), new EndEventHandler (MyEndMethod)
These two methods will be called after PreRender Event. To catch the idea look at the picture below.

Taken from
Async processing benefits are depicted in