You are previewing Pro ASP.NET 4 CMS: Advanced Techniques for C# Developers Using the .NET 4 Framework.
O'Reilly logo
Pro ASP.NET 4 CMS: Advanced Techniques for C# Developers Using the .NET 4 Framework

Book Description

To be a successful ASP.NET 4 developer, you need to know how to apply the vast array of new functionality available in the latest release of the .NET 4 Framework and Visual Studio 2010.

This book will immerse you in a variety of advanced topics, including architecting different application data tiers, memory caching paradigms, data mining, and search engine optimization. Working through step-by-step exercises using P/LINQ, DLR, MEF, MVC, IronPython, Axum, and Ajax, you will learn a variety of approaches to building each of the key application tiers common to all web solutions.

Using a proven technique of illustrating advanced concepts with functional solutions, all topics in the book are modeled on a fully operational content management system (CMS), built from the ground up. This ensures that you'll be introduced to real-world examples that demonstrate the full functionality of the .NET 4 Framework for ASP.NET, and that you'll be able to apply your new skills to any web development situation.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
    1. About This Book
      1. What You Need to Use This Book
      2. Code Samples
      3. Feedback
  6. 1. Visual Studio 2010 and .NET 4
    1. 1.1. Who This Book Is For
    2. 1.2. Who This Book Is Not For (or "Buy Me Now, Read Me Later")
    3. 1.3. What's New in .NET 4
      1. 1.3.1. C# Optional and Named Parameters
      2. 1.3.2. C#'s dynamic Keyword
      3. 1.3.3. Dynamic and Functional Language Support
      4. 1.3.4. Parallel Processing
        1. 1.3.4.1. Parallel LINQ (PLINQ)
        2. 1.3.4.2. Task Parallel Library (TPL)
        3. 1.3.4.3. Axum
      5. 1.3.5. Managed Extensibility Framework (MEF)
      6. 1.3.6. Distributed Caching with Velocity
      7. 1.3.7. ASP.NET MVC
    4. 1.4. A Tour of Visual Studio 2010
      1. 1.4.1. Windows Presentation Foundation
      2. 1.4.2. Historical Debugging
      3. 1.4.3. Improved JavaScript IntelliSense
      4. 1.4.4. jQuery Support
    5. 1.5. Building a CMS
      1. 1.5.1. CMS Functional Requirements
      2. 1.5.2. Creating the Application Framework
    6. 1.6. Summary
  7. 2. CMS Architecture and Development
    1. 2.1. Motivations for Building a CMS
    2. 2.2. Motivations for Using .NET
    3. 2.3. Application Architecture
      1. 2.3.1. The CMS Application Tiers
      2. 2.3.2. CommonLibrary: The Data Transfer Objects
      3. 2.3.3. GlobalModule: The HttpModule
    4. 2.4. Components of a CMS Page
      1. 2.4.1. Buckets
      2. 2.4.2. Embeddable Objects
      3. 2.4.3. Embeddable Permissions
    5. 2.5. Handling CMS Content
      1. 2.5.1. The Content Table
      2. 2.5.2. The ContentVersion Table
      3. 2.5.3. Assembling Content on Demand
      4. 2.5.4. How Embeddable Objects Handle Versions
    6. 2.6. Summary
  8. 3. Parallelization
    1. 3.1. What Is Parallelization?
      1. 3.1.1. Good Parallelization Candidates
      2. 3.1.2. Differences from Multithreading
    2. 3.2. Parallel Pitfalls
      1. 3.2.1. Deadlocks
      2. 3.2.2. Race Conditions
      3. 3.2.3. Thread Starvation
      4. 3.2.4. Amdahl's Law
    3. 3.3. .NET 4 Parallelization Concepts
      1. 3.3.1. Task vs. Data Parallelism
    4. 3.4. Task Parallel Library
      1. 3.4.1. Task.Wait()
      2. 3.4.2. Parallel.For() and Parallel.ForEach()
    5. 3.5. Parallel LINQ (aka PLINQ)
      1. 3.5.1. .AsParallel()
    6. 3.6. CMS Parallelization Opportunities
      1. 3.6.1. Creating a Data Mining Embeddable
      2. 3.6.2. Expanding the Data Mining Tasks
    7. 3.7. Tagging
      1. 3.7.1. Tagging on the Client
      2. 3.7.2. Fleshing Out the Tagging Embeddable
      3. 3.7.3. What's in a Name?
      4. 3.7.4. Handling Tag Input
      5. 3.7.5. Tag Processing in the Business Tier
      6. 3.7.6. POST Problems
      7. 3.7.7. Finalizing Tag Storage
      8. 3.7.8. Inserting Tags
      9. 3.7.9. Content Tags
    8. 3.8. Summary
  9. 4. Managed Extensibility Framework and the Dynamic Language Runtime
    1. 4.1. Managed Extensibility Framework
      1. 4.1.1. The Manual Way
      2. 4.1.2. The MEF Way
      3. 4.1.3. Working from Usage to Implementation
      4. 4.1.4. Exposing Libraries via MEF
      5. 4.1.5. A Simple Plug-in Contract
      6. 4.1.6. Implementing the Plug-In
      7. 4.1.7. Using the Plug-In
      8. 4.1.8. Catalogs and Containers
      9. 4.1.9. Supporting Multiple Parts
    2. 4.2. Dynamic Language Runtime
      1. 4.2.1. The dynamic Keyword
      2. 4.2.2. Benefits of the dynamic Keyword
    3. 4.3. CMS Plug-Ins
      1. 4.3.1. IEmbeddable
      2. 4.3.2. Server Controls as Embeddables
      3. 4.3.3. Displaying Embeddables
      4. 4.3.4. PageAssembler
    4. 4.4. Additional Methodology Benefits
      1. 4.4.1. Missing DLLs
      2. 4.4.2. Exceptions in Embeddables
    5. 4.5. A More Complex Emeddable
      1. 4.5.1. Breadcrumbs
      2. 4.5.2. Navigating the CMS Tree
    6. 4.6. Summary
  10. 5. jQuery and Ajax in the Presentation Tier
    1. 5.1. An Introduction to jQuery
      1. 5.1.1. The $() Factory
      2. 5.1.2. Implicit Iteration
    2. 5.2. Ajax via jQuery
      1. 5.2.1. Caching and Ajax
      2. 5.2.2. Avoiding Caching on GET Requests
      3. 5.2.3. Lightweight Content Delivery with Ajax and HTTP Handlers
      4. 5.2.4. Handling Asynchronous Errors
      5. 5.2.5. Handling DOM Modifications
    3. 5.3. Improving the CMS Admin with jQuery
      1. 5.3.1. Creating Collapsible Panels
      2. 5.3.2. Expanding with jQuery
      3. 5.3.3. Displaying the JavaScript Disabled Message
    4. 5.4. Poka-Yoke Devices
    5. 5.5. Summary
  11. 6. Distributed Caching via Memcached
    1. 6.1. What Is a Distributed Cache, and Why Is it Important?
    2. 6.2. Memcached
      1. 6.2.1. Acquiring a Memcached Client Library
      2. 6.2.2. Getting Started with Memcached
        1. 6.2.2.1. Using the Client Libraries Directly
        2. 6.2.2.2. Writing a Memcached Library
        3. 6.2.2.3. Testing the Library
        4. 6.2.2.4. Deleting Objects from the Cache
      3. 6.2.3. Complex Object Types
      4. 6.2.4. Protocol Considerations
      5. 6.2.5. Memcached Internals and Monitoring
    3. 6.3. Building a Cache-Friendly Site Tree
      1. 6.3.1. Visualizing the Tree
      2. 6.3.2. Defining a Node
      3. 6.3.3. Defining the Tree
      4. 6.3.4. Finding Nodes
      5. 6.3.5. Inserting Nodes
      6. 6.3.6. Serializing/Deserializing the Tree for Memcached Storage
    4. 6.4. Memcached Configuration Considerations
    5. 6.5. Summary
  12. 7. Scripting via IronPython
    1. 7.1. How Does the CMS Benefit from Scripting Capabilities?
      1. 7.1.1. Easier Debugging
      2. 7.1.2. Rapid Prototyping
    2. 7.2. An Introduction to IronPython and Its Syntax
      1. 7.2.1. What Is IronPython?
      2. 7.2.2. Installing IronPython
      3. 7.2.3. The IronPython Type System
      4. 7.2.4. Creating Classes and Controlling Scope
      5. 7.2.5. Constructors as Magic Methods
      6. 7.2.6. self
      7. 7.2.7. Exception Handling
      8. 7.2.8. Conditional Logic, Iterators, and Collections
      9. 7.2.9. Accessors and Mutators
    3. 7.3. Assembly Compilation
      1. 7.3.1. Compiling IronPython Code to a DLL
      2. 7.3.2. Compiling IronPython Code to an Executable
    4. 7.4. Building Scripting Capabilities into the CMS
      1. 7.4.1. Handling Script Files Between Tiers
      2. 7.4.2. Calling Scripts for a CMS Page
      3. 7.4.3. A Simple Scripting Example
    5. 7.5. Summary
  13. 8. Performance Tuning, Configuration, and Debugging
    1. 8.1. The CMS Definition of Performance
      1. 8.1.1. Latency
      2. 8.1.2. Throughput
    2. 8.2. Establishing Baselines
      1. 8.2.1. Component vs. System Baselines
    3. 8.3. The Web Capacity Analysis Tool
      1. 8.3.1. Installing WCAT
      2. 8.3.2. WCAT Concepts
      3. 8.3.3. Configurations
      4. 8.3.4. Scenarios
      5. 8.3.5. Running a WCAT Test Against the CMS
      6. 8.3.6. Interpreting Performance Results
    4. 8.4. Improving CMS Performance with Caching
      1. 8.4.1. HTTP.sys and the OutputCache
      2. 8.4.2. Benchmarking CMS Performance
    5. 8.5. Configuration Considerations
      1. 8.5.1. Enable Release Mode for Production
      2. 8.5.2. Removing the Server, X-Powered-By, and X-AspNet-Version Headers
    6. 8.6. Debugging Concepts
      1. 8.6.1. White-Box vs. Black-Box Debuggers
      2. 8.6.2. User Mode vs. Kernel Mode
    7. 8.7. Historical Debugging via IntelliTrace
    8. 8.8. Collaborative Debugging
      1. 8.8.1. Importing and Exporting Breakpoints
      2. 8.8.2. DataTip Pinning and Annotation
    9. 8.9. Summary
  14. 9. Search Engine Optimization and Accessibility
    1. 9.1. An Introduction to Search Engine Optimization
      1. 9.1.1. Science or Dark Art?
      2. 9.1.2. General Guidelines
        1. 9.1.2.1. Establishing Clear Markup
        2. 9.1.2.2. HTML Metadata the .NET 4 Way
        3. 9.1.2.3. Graceful JavaScript Degradation
        4. 9.1.2.4. Providing alt Text for Images
        5. 9.1.2.5. Color Scheme Sensitivity
    2. 9.2. Friendly URLs
      1. 9.2.1. Data Requirements for Friendly URLs
      2. 9.2.2. Stored Procedures for Friendly URLs
      3. 9.2.3. Exploiting the Page Life Cycle
      4. 9.2.4. Request Exclusion
      5. 9.2.5. Retrieving Friendly URLs
      6. 9.2.6. Retrieving Alias URLs and Response.RedirectPermanent()
    3. 9.3. Summary