Performance has been a concern of ours throughout this book, and we have endeavored to provide you production-ready code that will perform well in any setting. And when a recipe involves trade-offs between performance and ease of implementation, we strive to bring these to your attention. Nevertheless, when an application is not performing as well as you would like, you can often improve matters by altering its handling of the following elements:


You can often improve a page's performance by disabling the ViewState for the page or some of its controls, but you have to be aware of the consequences.

String manipulation

You've probably heard that it is better to use the StringBuilder object to build strings rather than the classic concatenation operators ( & and + ). But you may be wondering just how much better and whether it really applies to your situation.

Data access

With the different options available for data access, it's little wonder that there are ways to improve data access performance, especially when choosing between the two primary methods for reading data from a database ”i.e., via a DataReader or a DataAdapter .

SQL Server managed provider

For the sake of database interoperability, the bulk of the recipes in this book show how to access data using the OleDB managed provider. Yet because of the performance that can be garnered, there is much to be said for using the SQL Server managed provider instead when you know the application will always access SQL Server 7.0 or later.

All of these topics are addressed in the recipes in this chapter.

Like all other programming tools, ASP.NET and the common language runtime (CLR) provide many different ways to accomplish a given task. And because each application is unique and there is no one "right" way to approach it, we believe that every application's performance is worthy of review, mitigated by its frequency of use and its significance. With this in mind, you may want to consider these performance-oriented recipes as much for their approaches to performance tuning as for their line-for-line coding techniques.

As you evaluate the comparisons we've made in this chapter between different data access methods, you should know that the measurements were made on a 1.7 GHz Pentium 4 PC with 1G of memory. Your mileage may vary.

The side-by-side test results presented in this chapter's examples should be used to compare the relative difference between data access methods. The actual time to retrieve data is a function of the hardware, the database, the fragmentation of the data, and other variables .

ASP. NET Cookbook
ASP.Net 2.0 Cookbook (Cookbooks (OReilly))
ISBN: 0596100647
EAN: 2147483647
Year: 2006
Pages: 179

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: