Introduction

Over the last year or so, an incredible amount of industry attention has been paid to Microsoft’s new .NET Framework. It is the platform that will drive Microsoft’s technology direction for at least the next five years. With so much at stake, developers have been clamoring to get their hands on anything and everything .NET.

The web portion of the multidimensional .NET Framework is ASP.NET. ASP.NET is the next generation of the Active Server Pages web-development platform, and it represents a quantum leap forward with respect to its feature set and scalability. With its newfound power, however, comes increased complexity.

This book is designed to address many of the problems and issues that developers will most assuredly face as they begin developing web applications using ASP.NET. Specifically, it introduces tried-and-true web-development strategies that reduce the risk of bugs and also enable bugs to be tracked down more easily when they do occur. This book also introduces the myriad new debugging tools that are available in ASP.NET and demonstrates how to use them effectively. Finally, this book tackles the issues and problems associated with each aspect of ASP.NET, showing potential error messages and explaining how to fix their causes.

By no means is this book a troubleshooting compendium. There is simply no way to account for all possible errors and bugs that can be encountered in an ASP.NET web application. Instead, this book gives solid advice on how to build bug-free web applications, gives you a firm understanding of the debugging tools that are at your disposal, and explains how to handle some of the more common errors and bugs that occur. When you finish this book, you should be confident enough to find and eliminate any bug that you encounter in your ASP.NET web application.

Who Will Benefit from This Book?

The intended audience for this book is intermediate to experienced developers and project managers. The persons responsible for establishing project coding standards, mentoring junior-level developers, and debugging web applications will get the most benefit from this book. The reader should be familiar with developing ASP.NET web applications with either Visual Basic .NET or C# (all code examples are provided in both languages). Some of the key skills that the reader will learn from this book are listed here:

  • How to write code that reduces the chance of bugs

  • Solid strategies for debugging large web applications

  • How to leverage the many debugging tools available in ASP.NET, such as tracing, event logging, and conditional compiling

  • How to track down bugs associated with specific parts of ASP.NET, such as User Controls, caching, ADO.NET, and web services

  • Some of the caveats and issues common to migrating traditional ASP web applications to ASP.NET

Who Is This Book Not For?

This book is not for junior-level developers or for developers who are not relatively comfortable developing web applications with ASP.NET. It is not an ASP.NET tutorial; many other books on the market accomplish this task very well. Likewise, this book assumes that the reader is familiar with either Visual Basic .NET, C#, or both. The reader will not be able to understand and use the code examples without this knowledge.

Organization of This Book

The book parts and chapters are outlined in the next several sections.

Part I: ASP Debugging Basics

Chapter 1, “Conceptual Framework,” explains some of the new concepts introduced with ASP.NET, such as server-side events, the ASP.NET page life cycle, and the new language options available.

Chapter 2, “Traditional Approaches to Debugging in ASP,” covers some of the approaches used to debug traditional ASP web applications. It highlights several of the problems and shortcomings with the limited tools that were available.

Chapter 3, “Debugging Strategies,” outlines several plans of attack for debugging ASP.NET web applications. This includes debugging application tiers individually and distilling complex code into smaller, more manageable pieces.

Chapter 4, “Code Structure That Eases Debugging,” gives advice on how to build code that is both less likely to contain bugs and easier to debug when bugs creep in. Topics include code partitioning, control-of-flow guidelines, structured exception handling, and global exception handling.

Part II: ASP.NET Debugging Tools

Chapter 5, “Conditional Compiling,” covers how to take advantage of function attributes and preprocessor directives to dynamically add debugging code to your web applications.

Chapter 6, “Tracing,” shows you how to use the new TraceContext object available in ASP.NET and interpret its results. Trace configuration at both the page and the application levels is covered, as is using the Trace Viewer utility.

Chapter 7, “Visual Studio .NET Debugging Environment,” introduces all the powerful debugging features packed into the Visual Studio .NET IDE. Some of the topics covered include how to set breakpoints, the call stack, the watch window, inline ASP.NET page debugging, and how to attach to processes.

Chapter 8, “Leveraging the Windows 2000 Event Log,” explains how to write data to the Windows 2000 Event Log. Some of the things you will learn in this chapter include how to create custom event logs, how to handle both expected and unexpected events, and how to access the contents of the Windows 2000 Event Log via the web.

Part III: Debugging the New ASP.NET Features

Chapter 9, “Debugging Server-Side Controls,” takes you through the process of creating a custom server control, outlining many of the issues that you might encounter. Practical advice and solutions for these issues are provided.

Chapter 10, “Debugging Data-Bound Controls,” takes a close look at some of the common mistakes that can be made while using data-bound server controls. DataGrid, DataList, and the XML data binding are a few of the topics covered.

Chapter 11, “Debugging User Controls,” covers many of the issues that you might encounter while building user controls. The basics are covered, as are properties, methods, and dynamic user control issues.

Chapter 12, “Caching Issues and Debugging,” delves into the types of issues that crop up when leveraging caching in ASP.NET web applications. Highlights of this chapter include cache dependencies, output caching, the caching API, expiration callbacks, and declarative attributes.

Part IV: Debugging Related Technologies

Chapter 13, “Debugging Web Services,” uncovers and offers solutions for many of the problems that you might encounter while building and implementing web services. Several different error messages are discussed. Some of the other topics covered are the XMLSerializer, SOAP, and UDDI.

Chapter 14, “Debugging .NET Components and HttpHandlers,” explains how to use the StackTrace and TextWriterTraceLister objects to track down bugs in .NET components and HttpHandlers. The chapter also discusses issues with interfaces and state management.

Chapter 15, “COM+ Issues,” covers the problems and issues that can occur when setting up components to leverage COM+. It also covers some of the runtime anomalies that might occur in the context of COM+.

Chapter 16, “Debugging ADO.NET,” helps you interpret ADO.NET error messages, as well as track down bugs associated with each of the new ADO.NET objects. Database permissions issues are also briefly discussed.

Appendix

Appendix A, “Issues That Arise When Migrating from ASP to ASP.NET”, is a collection of issues that you are likely to run into while porting your traditional ASP web applications to ASP.NET. The new declaration syntax for script blocks is discussed along with many other useful topics, such as page declaratives, events, and cookies.

Source Code and Errata

All the source code provided in this book can be downloaded from www.debuggingasp.net. Also available at the site are any corrections and updates to the text. The errata will be updated as issues are discovered and corrected.

Conventions

This book follows these typographical conventions:

  • Listings, functions, variables, and other “computer language” are set in a fixed-pitch font—for example, “you should note the addition of the RUNAT="server" parameter added to each control.”

  • Code Continuation characthers

    are inserted into code when a line is too wide to fit into margins.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset