In this book, we discussed the concepts underlying ASP.NET and shared the reasons behind some of the design decisions. In each chapter, we offered tips that can help make your development experience more productive, improve the performance of your application, and help you to better understand ASP.NET. This appendix is a compilation of the tips in the book. They are grouped by chapter and appear in the order in which they appear in each chapter.
In Chapter 1, we focused on how ASP.NET interacts with the Web server to receive and handle requests. We examined the application-processing pipeline and looked at how HttpHandlers and HttpModules are key to the ASP.NET architecture.
When implementing an IHttpHandler, you can get improved performance if ASP.NET is able to reuse a single instance of the handler. The object must be stateless to avoid introducing bugs related to multithreading.
The final HttpHandler or HttpHandlerFactory might never be invoked if one of the HttpModules ends the request. This can minimize the load on the server when requests are serviced from the cache. When a request fails authentication or authorization checks, there is also no need to execute the handler.
The order in which HttpModules registered for an event is called is not guaranteed. Do not count on one HttpModule being called before another.
There is a certain amount of overhead related to throwing exceptions in the .NET Framework. Avoid throwing an excessive number of exceptions as part of the regular course of an application.
Server.Transfer is essentially the equivalent of Response.End followed by a call to Server.Execute.
Add validators to the wizard pages that verify that the set of expected values is in session. If all the required values aren’t present, redirect the user to the step where the first missing piece is to be submitted.
Add validators at each step of the wizard to enforce the entering of correct input by the user. Let the user proceed only after the values accumulated to that point are satisfactory and errors are corrected, because gathering missing information becomes more complicated after the user reaches the end of the wizard.