ASP.NET 3.5 Website Programming: Problem-Design-Solution

Book description

  • Uses the popular Problem;Design;Solution format to help readers, especially those who know how to code specific ASP.NET features, learn to "put it all together" into a complete Web application

  • Emphasizes n-tier ASP.NET Web application architectural design, something intermediate and advanced ASP.NET developers need and can't find anywhere else

  • Current edition is the most popular and discussed book in the p2p.wrox.com reader discussion forums

  • Covers registration and membership system, user-selectable themes, content management systems, polls, mailing lists, forums, e-commerce stores, shopping carts, order management with real-time credit-card processing, localization, and other site features

  • Developers also learn to handle master pages, themes, profiles, Web parts, server-side UI controls, compilation, deployment, instrumentation, error handling and logging, data access with ADO.NET and LINQ, ASP.NET AJAX, and much more

Table of contents

  1. Copyright
  2. About the Author
  3. Credits
  4. Acknowledgments
  5. Introduction
    1. 0.1. Who This Book Is For
    2. 0.2. What This Book Covers
    3. 0.3. How This Book Is Structured
    4. 0.4. What You Need to Use This Book
    5. 0.5. Conventions
    6. 0.6. Source Code
    7. 0.7. Errata
    8. 0.8. p2p.wrox.com
  6. 1. Introducing the Project: TheBeerHouse
    1. 1.1. Problem
    2. 1.2. Design
    3. 1.3. Solution
    4. 1.4. Summary
  7. 2. Developing the Site Design
    1. 2.1. Problem
    2. 2.2. Design
      1. 2.2.1. Designing the Site Layout
        1. 2.2.1.1. Technologies Used to Implement the Design
        2. 2.2.1.2. Using CSS to Define Styles in Stylesheet Files
        3. 2.2.1.3. Avoid Using HTML Tables to Control Layout
      2. 2.2.2. Sharing the Common Design among Multiple Pages
        1. 2.2.2.1. Enter the Master Page Model
        2. 2.2.2.2. Nested Master Pages
        3. 2.2.2.3. Accessing the Master Page from the Content Page
        4. 2.2.2.4. Switching Master Pages at Runtime
      3. 2.2.3. Creating a Set of User-selectable Themes
      4. 2.2.4. Creating a Navigation System
      5. 2.2.5. Creating XHTML-Compliant and -Accessible Sites
      6. 2.2.6. Sharing a Common Behavior among All Pages
    3. 2.3. Solution
      1. 2.3.1. Creating the Site Design
      2. 2.3.2. Creating the Master Page
        1. 2.3.2.1. Creating the Header Element
        2. 2.3.2.2. Creating a Menu with CSS
        3. 2.3.2.3. Creating the Footer Section
        4. 2.3.2.4. Creating the Main Content Sections in Nested Master Pages
        5. 2.3.2.5. Creating a Three-Column Layout
      3. 2.3.3. Binding a BreadCrumb to the SiteMap
      4. 2.3.4. Creating the First Theme
      5. 2.3.5. Creating a Sample Default.aspx Page
      6. 2.3.6. Creating the Second Theme
      7. 2.3.7. Creating the ThemeSelector User Control
      8. 2.3.8. Creating Consistent Sidebar Content
      9. 2.3.9. Another Small Touch of Style
    4. 2.4. Summary
  8. 3. Planning an Architecture
    1. 3.1. Problem
    2. 3.2. Design
      1. 3.2.1. Creating a Common Class Library
      2. 3.2.2. Adding a Class Library to a Visual Studio Solution
      3. 3.2.3. Designing a Layered Infrastructure
      4. 3.2.4. Choosing a Data Store
      5. 3.2.5. Designing the Data Access Layer
        1. 3.2.5.1. Introduction to the Entity Framework
          1. 3.2.5.1.1. Entity SQL
          2. 3.2.5.1.2. Object Services
          3. 3.2.5.1.3. LINQ to Entities
          4. 3.2.5.1.4. Extending Entity Framework in an N-Tier Environment
        2. 3.2.5.2. Generating an Entity Framework Data Model
        3. 3.2.5.3. Customizing Relationships
        4. 3.2.5.4. Examining the Generated Entity Model
          1. 3.2.5.4.1. ObjectContext Constructors
          2. 3.2.5.4.2. The Default ObjectQuery
          3. 3.2.5.4.3. Updating an Entity
          4. 3.2.5.4.4. Working with the Partial Custom ObjectContext Class
      6. 3.2.6. Designing the Business Logic Layer
        1. 3.2.6.1. Building a Repository
          1. 3.2.6.1.1. Introducing the Repository Pattern
          2. 3.2.6.1.2. Reviewing a Repository
          3. 3.2.6.1.3. Examining a Repository
        2. 3.2.6.2. Examining an Entity Class
          1. 3.2.6.2.1. The IBaseEntity Interface
          2. 3.2.6.2.2. Extending an Entity
      7. 3.2.7. Caching Data for Better Performance
      8. 3.2.8. Choosing a Caching Strategy That Fits Your Needs
      9. 3.2.9. Transaction Management with ADO.NET Entity Framework
      10. 3.2.10. Storing Connection Strings and Other Settings
      11. 3.2.11. User Interface
        1. 3.2.11.1. A Base Page Class
        2. 3.2.11.2. Introducing the ListView Control
        3. 3.2.11.3. Paging and Sorting the ListView
        4. 3.2.11.4. Using the Update Panel with the ListView Control
        5. 3.2.11.5. A Standard Administration Form
      12. 3.2.12. Error Logging
      13. 3.2.13. Search Engine Optimization Techniques
        1. 3.2.13.1. Site-Level Optimizations
          1. 3.2.13.1.1. The www/non-www Canonical Issue
          2. 3.2.13.1.2. Use 301 Redirects Properly
          3. 3.2.13.1.3. Search-Engine-Friendly URLs and Site Structure
        2. 3.2.13.2. Page-Level Optimizations
          1. 3.2.13.2.1. The Title Tag
          2. 3.2.13.2.2. The Description META Tag
          3. 3.2.13.2.3. The Keyword META Tag
          4. 3.2.13.2.4. Add a Robots META Tag
          5. 3.2.13.2.5. Use Header Tags and Modifiers
          6. 3.2.13.2.6. Use Valid HTML
          7. 3.2.13.2.7. Company Information and Privacy Pages
      14. 3.2.14. Navigation
        1. 3.2.14.1. URL Rewriting
        2. 3.2.14.2. Custom SiteMap
          1. 3.2.14.2.1. Custom SiteMapProvider
          2. 3.2.14.2.2. SiteMaps.org File
          3. 3.2.14.2.3. Custom SiteMap File httpHandler
    3. 3.3. Solution
      1. 3.3.1. TheBeerHouse Configuration Section
      2. 3.3.2. Implementing Good Search Engine Optimization Techniques
        1. 3.3.2.1. The URLRewrite httpModule
        2. 3.3.2.2. Page-Level Optimizations
      3. 3.3.3. Configuring ELMAH
    4. 3.4. Summary
  9. 4. Membership and User Profiling
    1. 4.1. Problem
    2. 4.2. Design
      1. 4.2.1. Password Storage Mechanisms
      2. 4.2.2. Authentication Modes: Windows Security or Custom Login Form?
      3. 4.2.3. The Let's Do Everything on Our Own Approach
      4. 4.2.4. The Membership and MembershipUser Classes
        1. 4.2.4.1. The Provider Model Design Pattern
        2. 4.2.4.2. More Details about SqlMembershipProvider
        3. 4.2.4.3. Exploring the Default SQL Server Data Store
        4. 4.2.4.4. The Graphical Login Controls
          1. 4.2.4.4.1. The CreateUserWizard Control
          2. 4.2.4.4.2. The Login Control
          3. 4.2.4.4.3. The ChangePassword Control
          4. 4.2.4.4.4. The PasswordRecovery Control
          5. 4.2.4.4.5. The LoginStatus, LoginName, and LoginView Controls
        5. 4.2.4.5. Integrating ASP.NET AJAX Authentication
      5. 4.2.5. Setting Up and Using Roles
        1. 4.2.5.1. Using Roles to Protect Pages and Functions against Unauthorized Access
        2. 4.2.5.2. Integrating ASP.NET AJAX Roles Service
      6. 4.2.6. Setting Up and Using User Profiles
        1. 4.2.6.1. Accessing Profiles from Business Classes
        2. 4.2.6.2. Accessing the Profile for Users Other Than the Current User
        3. 4.2.6.3. Adding Support for Anonymous Users
        4. 4.2.6.4. Integrating the ASP.NET AJAX Profile Service
      7. 4.2.7. OpenId Identity Services
      8. 4.2.8. Designing Our Solution
    3. 4.3. Solution
      1. 4.3.1. The Configuration File
      2. 4.3.2. Creating the Login Box
      3. 4.3.3. The AccessDenied.aspx Page
      4. 4.3.4. Implementing OpenId Authentication
      5. 4.3.5. The UserProfile Control
        1. 4.3.5.1. Persisting Properties through the New Control State
        2. 4.3.5.2. Loading and Editing a Profile
      6. 4.3.6. The Register Page
      7. 4.3.7. The PasswordRecovery Page
      8. 4.3.8. The EditProfile Page
      9. 4.3.9. Creating an AJAX Login Dialog
      10. 4.3.10. Persisting the Favorite Theme between Sessions
      11. 4.3.11. The Administration Section
        1. 4.3.11.1. The Admin Master Page
        2. 4.3.11.2. The ManageUsers Administrative Page
        3. 4.3.11.3. The AddEditUser Administrative Page
        4. 4.3.11.4. ManageRoles.aspx Page
        5. 4.3.11.5. AddEditRole.aspx Page
    4. 4.4. Summary
  10. 5. News and Article Management
    1. 5.1. Problem
    2. 5.2. Design
      1. 5.2.1. Features to Implement
      2. 5.2.2. Designing the Database Tables
        1. 5.2.2.1. The tbh_Categories Table
        2. 5.2.2.2. The tbh_Articles Table
        3. 5.2.2.3. The tbh_Comments Table
      3. 5.2.3. Creating the Entity Model
      4. 5.2.4. Building Repository Classes
        1. 5.2.4.1. ArticleRepository
        2. 5.2.4.2. CategoryRepository
        3. 5.2.4.3. CommentRepository
      5. 5.2.5. Designing the Configuration Module
      6. 5.2.6. Designing the User Interface
        1. 5.2.6.1. Writing Articles with a WYSIWYG Text Editor
        2. 5.2.6.2. Uploading Files
        3. 5.2.6.3. Article List User Control
        4. 5.2.6.4. Producing and Consuming RSS Feeds
      7. 5.2.7. The Need for Security
    3. 5.3. Solution
      1. 5.3.1. The Database Solution
      2. 5.3.2. Implementing the Configuration Module
      3. 5.3.3. Implementing the Business Logic Layer
        1. 5.3.3.1. The Repositories
          1. 5.3.3.1.1. The BaseArticleRepository
          2. 5.3.3.1.2. The ArticleRepository
          3. 5.3.3.1.3. The CategoryRepository
          4. 5.3.3.1.4. The CommentRepository
        2. 5.3.3.2. The Article Class
        3. 5.3.3.3. The Category Class
        4. 5.3.3.4. The Comment Class
      4. 5.3.4. Implementing Gravatars
      5. 5.3.5. Implementing the User Interface
        1. 5.3.5.1. The ManageCategories.aspx Page
          1. 5.3.5.1.1. The ManageCategories.aspx.vb Code-Behind File
        2. 5.3.5.2. The AddEditCategory.aspx Page
          1. 5.3.5.2.1. The AddEditCategories.aspx.vb Code-Behind File
        3. 5.3.5.3. The ManageArticles.aspx Page
        4. 5.3.5.4. The AddEditArticle.aspx Page
          1. 5.3.5.4.1. The AddEditArticle.aspx.vb Code-behind File
        5. 5.3.5.5. The FileUploader.ascx User Control
        6. 5.3.5.6. The ManageComments.aspx Page
        7. 5.3.5.7. The AddEditComment.aspx File
        8. 5.3.5.8. The ShowCategories.aspx Page
        9. 5.3.5.9. The BrowseArticles.aspx Page
        10. 5.3.5.10. The ShowArticle.aspx Page
          1. 5.3.5.10.1. Collecting Comments with AJAX
          2. 5.3.5.10.2. The ShowArticle.aspx.vb Code-behind File
        11. 5.3.5.11. The RSSFeed HttpHandler
        12. 5.3.5.12. The RssReader.ascx User Control
          1. 5.3.5.12.1. The RssReader.ascx.cs Code-behind File
        13. 5.3.5.13. Configuring Security Settings
    4. 5.4. Summary
  11. 6. Opinion Polls
    1. 6.1. Problem
    2. 6.2. Design
      1. 6.2.1. Handling Multiple Votes
      2. 6.2.2. Designing the Database Tables
      3. 6.2.3. Designing the Configuration Module
      4. 6.2.4. Creating the Entity Data Model
      5. 6.2.5. Designing the Business Layer
        1. 6.2.5.1. The PollRepository
        2. 6.2.5.2. The PollOptionRepository
      6. 6.2.6. Designing the User Interface Services
    3. 6.3. Solution
      1. 6.3.1. Working on the Database
      2. 6.3.2. Implementing the Configuration Module
      3. 6.3.3. Implementing the Repositories
        1. 6.3.3.1. Implementing the PollRepository
        2. 6.3.3.2. Implementing the PollOptionRepository
      4. 6.3.4. Extending the Entity Model Entities
        1. 6.3.4.1. Extending the Poll Entity
        2. 6.3.4.2. Extending the PollOption Entity
      5. 6.3.5. Implementing the User Interface
        1. 6.3.5.1. The ManagePolls.aspx Page
          1. 6.3.5.1.1. The ManagePolls.aspx.vb Code-Behind File
        2. 6.3.5.2. The AddEditPoll.aspx page
          1. 6.3.5.2.1. The AddEditPoll.aspx.vb Code-Behind File
        3. 6.3.5.3. The PollBox.ascx User Control
          1. 6.3.5.3.1. The PollBox.ascx.vb Code-Behind File
          2. 6.3.5.3.2. Plugging the PollBox Control into the Site's Layout
        4. 6.3.5.4. The ArchivedPolls.aspx Page
          1. 6.3.5.4.1. The ArchivedPolls.aspx.vb Code-Behind File
    4. 6.4. Summary
  12. 7. Newsletters
    1. 7.1. Problem
    2. 7.2. Design
      1. 7.2.1. Creating and Sending E-mails
      2. 7.2.2. Managing Long Operations on the Server
      3. 7.2.3. Designing the Database Tables
      4. 7.2.4. Designing the Configuration Module
      5. 7.2.5. Designing the User Interface Services
    3. 7.3. Solution
      1. 7.3.1. Implementing the Configuration Module
      2. 7.3.2. Implementing the Data Access Layer
      3. 7.3.3. Implementing the Business Logic Layer
        1. 7.3.3.1. Extending the Newsletter Entity
        2. 7.3.3.2. Implementing the NewslettersRepository
      4. 7.3.4. Implementing the User Interface
        1. 7.3.4.1. The AddEditNewsletter.aspx Page
        2. 7.3.4.2. The ArchivedNewsletters.aspx Page
        3. 7.3.4.3. The NewsletterBox User Control
    4. 7.4. Summary
  13. 8. Forums
    1. 8.1. Problem
    2. 8.2. Design
      1. 8.2.1. Designing the Database Tables
      2. 8.2.2. Designing the Configuration Module
      3. 8.2.3. Designing the Business Layer
      4. 8.2.4. Designing the User Interface Services
    3. 8.3. Solution
      1. 8.3.1. Implementing the Database
      2. 8.3.2. Implementing the Data Access Layer
      3. 8.3.3. Implementing the Business Logic Layer
      4. 8.3.4. Implementing the User Interface
        1. 8.3.4.1. Administering and Viewing Forums
        2. 8.3.4.2. The AddEditPost.aspx Page
        3. 8.3.4.3. The ManageUnapprovedPosts.aspx Page
        4. 8.3.4.4. The BrowseThreads.aspx Page
        5. 8.3.4.5. The MoveThread.aspx Page
        6. 8.3.4.6. The ShowThread.aspx Page
        7. 8.3.4.7. Producing and Consuming RSS Feeds
        8. 8.3.4.8. Securing the Forum Module
    4. 8.4. Summary
  14. 9. E-Commerce Store
    1. 9.1. Problem
    2. 9.2. Design
      1. 9.2.1. Choosing an Online Payment Solution
        1. 9.2.1.1. Implementing HTML Forms
        2. 9.2.1.2. Implementing Fully Integrated Payments
        3. 9.2.1.3. Using PayPal as the Payment Service
      2. 9.2.2. Designing the Database Tables
      3. 9.2.3. Designing the Configuration Module
      4. 9.2.4. Designing the Entity Model
      5. 9.2.5. Designing the Business Layer
      6. 9.2.6. Designing the User Interface Services
    3. 9.3. Solution
      1. 9.3.1. Implementing the Business Logic Layer
      2. 9.3.2. Implementing the User Interface
        1. 9.3.2.1. Implementing the Store Administration Pages
        2. 9.3.2.2. Implementing the Consumer Interface
        3. 9.3.2.3. The ShowProduct.aspx Page
        4. 9.3.2.4. The AvailabilityImage Web Control
        5. 9.3.2.5. The ShoppingCart.aspx Page
        6. 9.3.2.6. Handing the Customer's Return from PayPal
        7. 9.3.2.7. The ShoppingCart.ascx User Control
        8. 9.3.2.8. The FeaturedProduct.ascx Control
        9. 9.3.2.9. The OrderHistory.aspx Page
        10. 9.3.2.10. The ManageOrders.aspx and AddEditOrder.aspx Pages
      3. 9.3.3. Creating a Policies and Procedures Page
    4. 9.4. Summary
  15. 10. Calendar of Events
    1. 10.1. Problem
    2. 10.2. Design
      1. 10.2.1. Designing the Database Tables
      2. 10.2.2. Creating the Entity Data Model
      3. 10.2.3. Designing the Business Layer
        1. 10.2.3.1. The EventRepository
        2. 10.2.3.2. The EventRSVPRepository
      4. 10.2.4. Designing the User Interface Services
        1. 10.2.4.1. The vCalendar Httphandler
        2. 10.2.4.2. Dealing with Null Values
    3. 10.3. Solution
      1. 10.3.1. Implementing the Repositories
        1. 10.3.1.1. Implementing the EventRepository
        2. 10.3.1.2. Implementing the EventRSVPRepository
      2. 10.3.2. Extending the Entity Model Entities
      3. 10.3.3. Implementing the User Interface
        1. 10.3.3.1. The ManageEvents.aspx page
        2. 10.3.3.2. The AddEditEvent.aspx page
        3. 10.3.3.3. The BrowseEvents.aspx Page
          1. 10.3.3.3.1. The BrowseEvents.aspx.vb Code-Behind File
          2. 10.3.3.3.2. MakeEventRSVP.aspx Page
    4. 10.4. Summary
  16. 11. Photo Gallery
    1. 11.1. Problem
    2. 11.2. Design
      1. 11.2.1. Designing the Database Tables
      2. 11.2.2. Creating the Entity Data Model
      3. 11.2.3. Designing the Business Layer
        1. 11.2.3.1. The AlbumRepository
        2. 11.2.3.2. The PictureRepository
      4. 11.2.4. Designing the Configuration Module
      5. 11.2.5. The Photo Gallery Storage
      6. 11.2.6. Designing the User Interface Services
    3. 11.3. Solution
      1. 11.3.1. Implementing the Repositories
        1. 11.3.1.1. Implementing the AlbumRepository
        2. 11.3.1.2. Implementing the PictureRepository
      2. 11.3.2. Extending the Entity Model Entities
        1. 11.3.2.1. Extending the Picture Entity
        2. 11.3.2.2. The GalleryHelper
        3. 11.3.2.3. The GalleryImage Class
      3. 11.3.3. Implementing the User Interface
        1. 11.3.3.1. The ManageAlbums.aspx Page
        2. 11.3.3.2. The AddEditAlbum.aspx Page
        3. 11.3.3.3. The AddEditPhoto.aspx Page
        4. 11.3.3.4. The BrowseAlbums.aspx Page
        5. 11.3.3.5. ShowAlbum.aspx Page
        6. 11.3.3.6. Implementing an AJAX Lightbox
    4. 11.4. Summary
  17. 12. Localizing the Site
    1. 12.1. Problem
    2. 12.2. Design
      1. 12.2.1. Localization Features of ASP.NET
        1. 12.2.1.1. Using Global Resources
        2. 12.2.1.2. Using Page-Level Resources
        3. 12.2.1.3. Localizing More Static Content
        4. 12.2.1.4. Specifying Alternate Language Pages
        5. 12.2.1.5. Setting the Current Culture
    3. 12.3. Solution
      1. 12.3.1. Localizing ASP.NET AJAX
    4. 12.4. Summary
  18. 13. Deploying the Site
    1. 13.1. Problem
    2. 13.2. Design
      1. 13.2.1. Deploying the Database to SQL Server 2008
        1. 13.2.1.1. Create the Standard ASP.NET Objects
        2. 13.2.1.2. Script All Your Database Objects
        3. 13.2.1.3. Importing Existing Data
      2. 13.2.2. Deploying the Site
        1. 13.2.2.1. Copying the Site Locally or Remotely
        2. 13.2.2.2. Precompiling the Site
        3. 13.2.2.3. Using the Visual Studio Web Deployment Projects
        4. 13.2.2.4. Creating an Installer for a Packaged Application
    3. 13.3. Solution
    4. 13.4. Summary

Product information

  • Title: ASP.NET 3.5 Website Programming: Problem-Design-Solution
  • Author(s):
  • Release date: October 2009
  • Publisher(s): Wrox
  • ISBN: 9780470187586