ASP. NET 2.0 Illustrated
Authors: Homer A. Sussman D.
Published year: 2006
Pages: 39-40/147
Buy this book on amazon.com >>


Summary

In this chapter, we have expanded on the data source control and data display control discussions of Chapters 3 and 4. We started by looking at some of the simple uses for the events of the data source controls, such as rebinding other display controls on the page and how to modify the parameters before a SelectCommand is executed.

We then moved on to output parameters and how to access values sent back from executed commands, such as the identity value of a newly inserted row. You saw that from within the event procedure, the way of accessing output parameters is the same whether using a SqlDataSource or ObjectDataSource control.

We then moved on to the ObjectDataSource using a strongly typed business class, and we showed how to implement custom paging so that the display controls can provide the same functionality that the SqlDataSource provides. The paging revolves around your business class supporting the use of the number of rows in a page and which row to start on, as well as knowing the total number of rows.

We then briefly saw an overview of the events for the GridView and DetailsView before moving into conflict detection and concurrency errors, detailing how to avoid the lost update problem. This section showed that events for the display controls are much more useful than the events on the data source controls, because the display control events provide access to all versions of the data being updated.

The second half of the chapter looked at one particular aspect of SQL Server CLR Integration, which is the use of custom types in database. We showed how to created a User-Defined Type to store mapping information, and then how that custom type can be used in client applications. You can see that this provides a simple way to create some exciting applications without having to worry about handling complex data, because the database and the UDT handle the data natively.

Now it's time to move into how to improve the performance of applications, so we'll take a look at caching.



6. Data and Output Caching

Caching is the act of storing something for later retrieval, and in the Web world it is used to improve performance. There are many factors that affect the performance of Web sites, and two of these are the processing of ASP.NET pages and fetching data from databases. Once a Web site has been launched, the pages themselves generally stay fairly static, with only data changing, and even then that doesn't always change frequently. Fetching data from a database is relatively slow and uses resources (process, memory, etc.), so if that usage can be minimized, performance can be improved. Likewise, if a page doesn't change, why process it on every request?

Both of these problems can be solved with cachingstoring data so that it doesn't have to be processed or fetched . The performance impact of reducing resource usage may not be noticeable on small sites, but for larger sites with many users you can achieve dramatic improvements. In this chapter we're going to look at various caching schemes and how they can be used to improve performance. In particular, we will cover the following topics:

  • Using the application, session, HttpContext, and viewstate to store data

  • How to use output caching to reduce processing overhead

  • How to cache data to reduce SQL Server resource usage

  • How to use cache notifications so that stale data is never shown

  • How to use the cache API

Some of these techniques are simple, while others require a little more thought. All of them, however, are easy to code.


ASP. NET 2.0 Illustrated
Authors: Homer A. Sussman D.
Published year: 2006
Pages: 39-40/147
Buy this book on amazon.com >>