Home > Store

Essential ASP.NET With Examples in C#

Register your product to gain access to bonus material or receive a coupon.

Essential ASP.NET With Examples in C#

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

With coverage not found in other titles and endorsed by the architects of ASP.NET, this book is essential for any serious ASP.NET developer

° Provides practical information on how to use ASP.NET, backed up by a solid understanding of how and why it works the way it does

° Based on the author's extensive experience teaching ASP.NET to professional developers

° Covers the upcoming release of ASP.NET, and is part of the authoritative Microsoft .NET Development Series

Description

  • Copyright 2003
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 432
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-76040-1
  • ISBN-13: 978-0-201-76040-8

Praise for Essential ASP.NET with Examples in C#

“Essential ASP.NET with Examples in C# is so good that it’s the only ASP.NET book on my working bookshelf.”

         —LARRY O’BRIEN, .NET Watch columnist, SD Times

“Essential ASP.NET is positioned to become the seminal book on the most important advancement to Web development in years.”

         —JUSTIN BURTCH, software engineer

“Fritz’s explanations are clear and concise without being patronizing; his examples are succinct without being trivial. I can now say that after reading Fritz’s book, and trying a few things out, I feel that I ‘know’ ASP.NET. Reading his book has been a very helpful experience.”

         —RICHARD GRIMES, .NET author and consultant

“Like many of the teachers who have worked with DevelopMentor, Fritz has a great ability to make complex concepts very easy to understand. The explanations go deep enough that I’ve had several ‘a ha’ moments while finally understanding how some features really worked.”

         —SCOTT SEELY, Microsoft Corporation

“This is an excellent book! It has a straightforward style and is comprehensive.”

         —DARYL RICHTER, software architect

“This book greatly improves the understanding of ASP.NET. The text is concise and examples are well written. The signal-to-noise ratio of this book is very high. I am sure it will be a great value to its readers.”

         —AMIT KALANI, software programmer/analyst

“Fritz Onion’s Essential ASP.NET is one of the best ASP.NET books I have read.”

         —JAMES EDELEN, Microsoft MVP

“It is deep enough that everyone is assured of learning something, no matter how experienced you may already be.”

         —PAUL WILSON, Software Architect, WilsonDotNet.com

“The book is a winner, and a must-have for experienced developers who want to augment their knowledge of ASP.NET by being aware of what goes on under the hood.”

         —JASON SALAS, MBA, MCP, and Web Development Manager for Pacific Telestations, Inc.

“If you are looking for an ASP.NET book that can help take you to the next level, Essential ASP.NET with Examples in C# is your first class ticket.”

         —ROBBE MORRIS, Senior Software Engineer, EggHeadCafe.com
"This well-conceived and well-written book has extensive knowledge and priceless experience overflowing from its pages. It captures the true essence of ASP.NET and walks the reader to a high level of technical and architectural skill."
--J. Fred Maples, Director of Software Engineering, NASDAQ.com

Essential ASP.NET with Examples in C# is the C# programmer's definitive reference for ASP.NET through version 1.1. It provides experienced programmers with the information needed to fully understand the technology, and is a clear guide to using ASP.NET to build robust and well architected Web applications.

This book begins with a discussion of the rationale behind the design of ASP.NET and an introduction to how it builds on top of the .NET framework. Subsequent chapters explore the host of new features in ASP.NET, including the server-side compilation model, code-behind classes, server-side controls, form validation, the data binding model, and custom control development. Throughout the book, working examples illustrate best practices for building Web-based applications in C#.

Among the topics explored in depth are:

  • ASP.NET architecture
  • Web forms
  • Configuration
  • HTTP pipeline
  • Diagnostics and error handling
  • Validation
  • Data binding
  • Custom controls
  • Caching
  • State management
  • Security
  • Essential ASP.NET with Examples in C# provides readers with the know-how needed to build more powerful, better architected Web applications with ASP.NET.



    Downloads

    Source Code

    Click below for Source Code related to this title:
    Source Code

    Sample Content

    Online Sample Chapter

    State Management in ASP.NET

    Downloadable Sample Chapter

    Click below for Sample Chapter(s) related to this title:
    Sample Chapter 10

    Table of Contents



    Foreword.


    Preface.


    1. Architecture.

    Fundamentals.

    ASP 4.0.

    Compilation versus Interpretation.

    System.Web.UI.Page.

    Code-Behind.

    Event Handling.

    Shadow Copying.

    Directives.

    The New Intrinsics.



    2. Web Forms.

    Server-Side Controls.

    ViewState.

    Events.

    A Day in the Life of a Page.

    Web Forms and Code-Behind.

    Root Path Reference Syntax.

    HtmlControls.

    WebControls.

    List Controls.

    WebControls versus HtmlControls.

    Building Web Forms with Visual Studio .NET.



    3. Configuration.

    web.config.

    Configuration Hierarchy.

    Location Element.

    Element Placement.

    Impact of Configuration Changes.

    IIS and web.config.

    Configuration Data.

    Process Model.

    Accessing Process Information.

    IIS 6.0 Process Model Changes.

    Additional Settings.

    Reading Configuration Information.

    Building a Custom Configuration Section Handler.

    Using the NameValueFileSectionHandler.



    4. HTTP Pipeline.

    A Day in the Life of a Request.

    Ten Thousand-Foot View of Request Processing.

    Inside the Pipeline.

    Context.

    Applications.

    Application Events.

    Declarative Object Creation.

    Custom Handlers.

    Custom Handlers for File Processing.

    .ashx.

    Handler Pooling.

    Custom Handler Factories.

    Custom Modules.

    Modules as Filters.

    Module Pooling.

    Modules versus global.asax.

    Threading in the Pipeline.

    Asynchronous Handlers.



    5. Diagnostics and Error Handling.

    Diagnostics in ASP.NET.

    Page Tracing.

    Writing Trace Messages.

    Application-Level Tracing.

    Performance Monitor Counters.

    Debugging.

    Error Handling.

    Unhandled Exceptions.



    6. Validation.

    Form Validation.

    Client-Side Validation.

    Server-Side Validation.

    Validation Observations.

    Validation Control Architecture.

    Page Validation.

    Client-Side Validation.

    Validation Controls.



    7. Data Binding.

    Fundamentals.

    Data Binding Controls.

    Binding to Database Sources.

    IDataReader Binding.

    DataSet Binding.

    DataSet versus DataReader for Data Binding.

    DataGrid.

    DataGrid Paging.

    DataGrid Sorting.

    DataGrid Editing.

    Templates.

    Data Binding Evaluation Syntax.

    DataBinder.

    Templated Controls.

    Repeater.

    DataList.



    8. Custom Controls.

    Fundamentals.

    Writing Custom Controls.

    Using Custom Controls.

    System.Web.UI.Control.

    HtmlTextWriter.

    Browser Independence.

    Subproperties.

    Inner Content.

    Generating Client-Side Script.

    System.Web.UI.WebControls.WebControl.

    State Management.

    ViewState.

    Explicit Post-Back Data Handling.

    Composite Controls.

    Creating Child Controls.

    Custom Events.

    User Controls.

    Validation and Data Binding.

    Supporting Validation.

    Data-Bound Controls.

    Implementing a Data-Bound Control.

    Designer Integration.

    Properties and Appearance.

    Type Converters.

    Property Editors.

    Designers.



    9. Caching.

    Caching Opportunities in ASP.NET.

    Output Caching.

    Output Caching Location.

    Caching Multiple Versions of a Page.

    Page Fragment Caching.

    Output Caching Considerations and Guidelines.

    Data Caching.

    Cache Entry Attributes.

    Cache Object Removal.

    Data Cache Considerations and Guidelines.



    10. State Management.

    Types of State.

    Application State.

    Session State.

    Session Key Management.

    Storing Session State out of Process.

    Cookie State.

    View State.



    11. Security.

    Web Security.

    Server Authentication.

    Client Authentication.

    Security in ASP.NET.

    Client Authentication and Authorization.

    Forms Authentication.

    Authentication Cookies in Web Farms.

    Optional Authentication.

    Password Storage.

    Salted Hashes.

    Role-Based Authentication.

    System Identity in ASP.NET.



    Index. 0201760401T02042003

    Preface

    It was late in the night in Torrance, California in August of 2000. I had spent 12 hours of the day teaching DevelopMentor's Guerrilla COM course with Mike Woodring and Jason Whittington. Don Box had come over after class and as usual, we were staying up late into the night after the students had long since gone to bed, discussing technology and hacking. Microsoft had just released their preview version of .NET at the PDC in July, and we had been spending much of the year up to that point digging into 'the next COM' and were excited that it had finally been released so we could talk about it. It was that evening, that Don, in his typical succinct way, showed me my first glimpse of ASP.NET (then called ASP+). He first typed into emacs a .aspx file that looked like see code in book. He then wrote another file that looked like see code in book. He then placed the two files in c:\inetpub\wwwroot on his machine and showed me the rendering of the .aspx page through the browser--exclaiming "get it?" Perhaps it was the late hour, or the fact that I had been teaching all day, but I have to admit that while I "got" the technical details of what Don was showing me, I was somewhat underwhelmed by being able to change the innerText of an h1 element from a class.

    The following week, after a couple of good nights of sleep, I came back and revisited the .aspx example, and began to explore ASP.NET in more detail. After a day of reading and experimenting, I finally "got it" and I was hooked. This technology was poised to fundamentally change the way people built web applications on Windows, and it took full advantage of the new .NET runtime. I spent the next six months researching, building ASP.NET applications, and writing DevelopMentor's Essential ASP.NET course, and I spent the subsequent year and a half teaching, speaking, and writing about ASP.NET. This book is the culmination of those activities, and I hope it helps you in your path to understanding ASP.NET.

    C# Versus VB.NET

    Prior to .NET, Visual Basic was not just another language--it was a platform unto itself. Building applications in Visual Basic 6.0 for example, was completely different from using C++ and MFC. With .NET, this distinction is gone, and Visual Basic is indeed just another .NET language that uses the same libraries, the same development tools, and the same runtime as all others. As a consequence, it is now possible to talk about technologies like ASP.NET from a language-neutral standpoint. The code samples, however, must be shown in a particular language, so this book is actually published in two versions--one with examples in C# and one with examples in VB.NET. All content outside the actual examples is nearly identical between the two books, and if you're interested, you can download all of the samples in either language from the book's web site http://www.develop.com/books/essentialasp.net/.

    Sample Code, Website, Feedback

    All of the code samples in this book are drawn from working samples available for display and download at http://www.develop.com/books/essentialasp.net/. This site also contains any errata found after publication, as well as a supplemental set of more extended examples of the concepts presented in this book for your reference. The author welcomes your comments, errata, and feedback via the forms available on the website.

    Prerequisites

    This book focuses exclusively on ASP.NET, and does not spend time reviewing .NET programming, object-oriented programming techniques, database access, or general web application development techniques. You will be able to get the most out of this book if you have spent some time gaining experience in each of these areas.

    Organization of This Book

    This book approaches ASP.NET from the ground up, beginning with a look at the core elements of the architecture in Chapter 1, and continuing with the server-side control model in Chapter 2. It is recommended that the reader be familiar with the contents of Chapters 1 and 2 before reading any of the subsequent chapters. However, all chapters after 2 can be read independently and in any desired sequence.

    Chapter 1, Architecture, covers the fundamentals of the ASP.NET architecture, beginning with a look at the parsing of .aspx files and their subsequent compilation into assemblies. This chapter explains the details of the Page class, demonstrates the new code-behind model, and discusses the shadow copy mechanism used to prevent file locking. The chapter concludes with a look at the new classes in ASP.NET that replace the intrinsic objects of traditional ASP.

    Chapter 2, Web Forms, looks at the control-based programming model supported in ASP.NET called web forms. This chapter looks at the details of state retention across post-backs using both POST body data as well as ViewState, and how to effectively use server-side controls to create dynamic web pages. The chapter concludes with a look at the various server-side controls available in ASP.NET.

    Chapter 3, Configuration, describes the configuration model used by ASP.NET, starting with the XML format used by all configuration files and the hierarchical application of configuration settings. This chapter inspects several configuration elements in detail, including the processModel and appSettings elements. The chapter concludes by demonstrating two techniques for adding custom configuration sections to your configuration files.

    Chapter 4, HTTP Pipeline, explores the details of the classes involved with servicing HTTP requests in ASP.NET. This chapter first walks through all of the elements in the HTTP pipeline used to process a request, and then discusses the three points of extensibility in the pipeline: 1) custom application classes, 2) custom handlers, and 3) custom modules. The chapter concludes with a discussion of threading and object pooling in the pipeline.

    Chapter 5, Diagnostics and Error Handling, covers the new diagnostic features of ASP.NET including page and application tracing as well as the new performance monitor counters. This chapter also discusses techniques for debugging ASP.NET applications and exception handling. The chapter concludes with a look at how to define custom error pages for your applications.

    Chapter 6, Validation, describes the new validation architecture built into ASP.NET. This chapter begins by looking at how validation is performed in web applications in general, and proceeds to show how ASP.NET's validation architecture provides a general solution to the problem of validating user input. The chapter includes a detailed look at how both client-side and server-side validation work, as well as a look at all of the available validation controls.

    Chapter 7, Data Binding, explores the process of binding server-side data to controls in an ASP.NET page. This chapter starts by explaining how data binding works with several different data sources including collection classes, DataReaders, and DataSets, and then looks at how to bind data to several controls, including the DataGrid class. The chapter concludes with a look at templates and how to use them effectively with the Repeater, DataList, and DataGrid classes.

    Chapter 8, Custom Controls, covers the fundamentals of building your own custom controls for use in ASP.NET applications. This chapter explains how custom controls are built, how to use the HtmlTextWriter class to achieve some browser independence, how to further support browser-independent rendering, how to define properties and sub-properties, how to extract the inner content of a control's tag, how to generate client-side script, and how to manage control state. The chapter also covers the details of building composite controls, user controls, controls that support validation, and controls that support data binding. The chapter concludes with a look at how to integrate your controls with the Visual Studio .NET designer.

    Chapter 9, Caching, looks at both output caching and data caching in ASP.NET. This chapter discusses the mechanism of output caching and how to precisely control which versions of a page are placed in the cache, as well as how to cache portions of a page using page fragment caching with user controls. The chapter explains how to use the new application-wide data cache, and includes a discussion of considerations and guidelines to observe when caching data.

    Chapter 10, State Management, discusses the various types of state in an ASP.NET web application and how and when to use each type. This chapter begins with a look at application state, and explains why it should typically be avoided in ASP.NET. It then looks at the improvements in session state including out of process storage and cookieless key management, as well as techniques for optimizing your use of session state. The chapter concludes with a look at using cookies and ViewState as alternatives, or in addition, to session state.

    Chapter 11, Security, describes the security features of ASP.NET and how to control client authentication and authorization in your applications. This chapter starts by reviewing the concepts of security for web applications, and then shows how to build and manage applications that need to authenticate clients using the forms authentication architecture provided by ASP.NET. The chapter also covers the management of authentication cookies in web farms, safe password storage, building role-based authentication systems, and how to control the process identity used by ASP.NET.

    Acknowledgments

    I would first like to thank my wife Susan and children Zoe and Sam who supported me without hesitation during the writing of this book. Thanks also to my parents, Pat and Dan Onion for their support and direction.

    Thanks to all of my colleagues at DevelopMentor for the many discussions and constant feedback both for the course and for this book. In particular, thanks to: Bob Beauchemin for his always timely and useful feedback; Keith Brown for showing me how to salt my hashes and otherwise reinforcing my security chapter; Simon Horrell for his detailed feedback; Dan Sullivan for leaving no stone unturned; Ted Pattison, for commiserating on writing, and for his always positive comments; Stu Halloway for making my writing more concise.

    Thanks to my official reviewers Justin Burtch, Amit Kalani, Daryl Richter, Martin Heller, Matt Milner all of whom provided invaluable feedback. Thanks to the members of the ASP.NET team at Microsoft for building such an interesting product, and for fielding many questions. In particular, thanks to Rob Howard for his input on caching and to Erik Olson for explaining thread allocation and pooling in the pipeline. Thanks to Don Box for introducing me to ASP.NET, and for getting my writing career started at C++ Report back in 1995.

    Thanks to my editor, Stephane Thomas, for all her hard work. Much gratitude also to the more than 1000 students that have taken the Essential ASP.NET course--your input has shaped the stories in this book more than anything else. Thanks in particular to the students at the Essential ASP.NET course offered in Washington D.C. in October of 2002 for helping choose the color of the book covers.

    Fritz Onion
    Wells, ME
    October 2002
    http://staff.develop.com/onion/


    0201760401P10232002

    Index

    Click below to download the Index file related to this title:
    Index

    Updates

    Submit Errata

    More Information

    InformIT Promotional Mailings & Special Offers

    I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

    Overview


    Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

    This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

    Collection and Use of Information


    To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

    Questions and Inquiries

    For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

    Online Store

    For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

    Surveys

    Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

    Contests and Drawings

    Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

    Newsletters

    If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

    Service Announcements

    On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

    Customer Service

    We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

    Other Collection and Use of Information


    Application and System Logs

    Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

    Web Analytics

    Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

    Cookies and Related Technologies

    This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

    Do Not Track

    This site currently does not respond to Do Not Track signals.

    Security


    Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

    Children


    This site is not directed to children under the age of 13.

    Marketing


    Pearson may send or direct marketing communications to users, provided that

    • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
    • Such marketing is consistent with applicable law and Pearson's legal obligations.
    • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
    • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

    Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

    Correcting/Updating Personal Information


    If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

    Choice/Opt-out


    Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

    Sale of Personal Information


    Pearson does not rent or sell personal information in exchange for any payment of money.

    While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

    Supplemental Privacy Statement for California Residents


    California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

    Sharing and Disclosure


    Pearson may disclose personal information, as follows:

    • As required by law.
    • With the consent of the individual (or their parent, if the individual is a minor)
    • In response to a subpoena, court order or legal process, to the extent permitted or required by law
    • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
    • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
    • To investigate or address actual or suspected fraud or other illegal activities
    • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
    • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
    • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

    Links


    This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

    Requests and Contact


    Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

    Changes to this Privacy Notice


    We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

    Last Update: November 17, 2020