O'Reilly logo

ASP.NET Site Performance Secrets by Matt Perdeck

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

Asynchronous generic handlers

When you use AJAX-type asynchronous requests from your page to retrieve data from the database, you would want to use an .ashx generic handler or maybe a web service to process that request, rather than a full-blooded .aspx page. This will save you the overhead of the full page life cycle.

Accessing a database asynchronously from a generic handler is different from doing the same from a page. Let's see how this works.

Synchronous version

Firstly, let's have a quick look at a synchronous generic handler. We'll then work that into its asynchronous counterpart using the asynchronous data access layer we just saw.

You'll find the code in the downloaded code bundle in the folder ThreadStarvation_Db_Sync, file Handler.ashx ...

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