Click here to Skip to main content
12,751,904 members (29,300 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 11 Oct 2013

Asynchronous Pages

, 18 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Improve the scalability of a website and efficient design for time consuming processes.

Editorial Note

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

Asynchronous Pages 


Improve the Scalability of website and efficient design for time consuming process.

Note: It should not be confused with Asynchronous request from Client side. AJAX used to improve the end user interface, where as Asynchronous pages handled in server side to provide efficient way of handling the request. It’s particularly used in web pages that include time consuming code that queries database.


.NET maintains a pool of threads to handle the incoming requests, when a request is received ASP.NET assigns a thread from its pool to process the request.

Let’s say we have a code that involves significant waiting time, so if all available threads were assigned to the incoming requests and its executing the time consuming code. The additional requests will be queued; if a limit is reached we will be getting “503 Server Unavailable errors”.

The possible waiting scenarios are: Large data from slow DBRead a file from Remote locationWeb service object…


If we create Asynchronous pages with time consuming code executing in a separate thread pool which will free up the ASP.NET thread pool to allow it for processing other requests. Once a separate thread completes its work ASP.NET assigns an available thread to complete the operation. This is not going to improve the performance by any way, tricky way to handle all requests effectively making your application scalable.


Step 1:

<%@ Page Async=”true” %> 

IHttpAsyncHandler will be implemented instead of IHttpHandler.

Step 2: 

AddOnPreRenderCompleteAsync(New BeginEventHandler  
   _(Addressof BeginTask), New EndEventHandler (Addressof EndTask)) 

This will be called when the page loads. 

  • BeginEventHandler - Launches Asynchronous task.
  • EndEventHandler - Handles callback from Asynchronous task.
  • BeginTask and EndTask are the methods assigned to the above delegates.

The page lifecycle will be as follows:

  • Init
  • Load
  • Controlevents
  • Prerender
  • BeginTask()
  • Asynchonous task
  • End Task()
  • PreRenderComplete
  • Savestate
  • Render


  • Initial ASP.NET thread
  • Another ASP.NET thread
  • Thread outside of ASP.NET thread pool


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

769 members

You may also be interested in...


Comments and Discussions

QuestionAny disadvantage/limitation of using Async pages Pin
pranavsingh23-Oct-13 4:36
memberpranavsingh23-Oct-13 4:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 18 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid