Professional IIS 7 and ASP.NET Integrated Programming

Book description

The deep integration of IIS7 and ASP.NET provides both IIS7 administrators and ASP.NET developers with new and exciting programming tools, techniques, and approaches that were not possible with earlier versions of IIS. With this book, Dr. Shahram Khosravi presents you with the only resource to focus exclusively on the key features of this exciting integration.

You'll get in-depth coverage of all the major systems that make up the IIS7 and ASP.NET integrated infrastructure, detailed explanations on how they work, guidance on how to use them in your own applications, and techniques for extending them to meet your application requirements.

Packed with detailed code walkthroughs and in-depth analyses of numerous real-world examples - all written and tested with Windows Vista, Windows Server 2008, ASP.NET 2.0, and ASP.NET 3.5 (Visual Studio 2008), this book helps you gain the skills, knowledge, and experience you need to use and to extend the major systems that make up the IIS7 and ASP.NET integrated infrastructure.

Some of the key topics covered include:

  • How to write integrated IIS7 and ASP.NET code that works with Windows Vista, Windows Server 2008, ASP.NET 2.0, and ASP.NET 3.5 (Visual Studio 2008)

  • Techniques for implementing and plugging custom HTTP modules, handlers, and handler factories into the IIS7 and ASP.NET integrated request processing pipeline

  • How to manage the IIS7 and ASP.NET integrated configuration system from IIS7 Manager, appcmd.exe, and managed code

  • Tips for using the IIS7 and ASP.NET integrated declarative schema extension markup language (<sectionSchema>, <attribute>, <element>, <collection>, and so on) to implement custom configuration sections

  • Techniques for using and extending the IIS7 and ASP.NET integrated managed code system (ConfigurationElement, ConfigurationElementCollectionBase<T>, ConfigurationSection, ApplicationPool, Site, Application, ServerManager and so on) to add support for custom managed classes

  • Tips for extending the IIS7 and ASP.NET integrated graphical management system (ModuleServiceProxy, ModuleDialogPage, ModuleListPage, TaskForm, Module, ModuleService, ModuleProvider, TextTaskItem, MethodTaskItem, and so on) to add new graphical components to IIS7 Manager

  • Techniques for using and extending the IIS7 and ASP.NET integrated providers system (ProviderConfigurationFeature, ProviderConfigurationSettings, IProviderConfigurationService, ConfigurationModuleProvider, and so on) and ways to implement and to plug custom provider-based services into this system and IIS7 Manager

  • Ways to use the IIS7 and ASP.NET integrated tracing and diagnostics - TraceSource, SourceSwitch, IisTraceListener, EventTypeFilter, RSCA, Request, WorkerProcess, Failed Request Tracing, and so on

  • ASP.NET and Windows Communication Foundation integration in IIS7

Table of contents

  1. Copyright
  2. About the Author
  3. Credits
  4. Acknowledgments
  5. Introduction
    1. Who This Book Is For
    2. What This Book Covers
    3. What You Need to Use This Book
    4. Conventions
    5. Source Code
    6. Errata
    7. p2p.wrox.com
  6. 1. IIS 7 and ASP.NET Integrated Architecture
    1. 1.1. Modular Architecture of IIS 7
      1. 1.1.1. IIS-WebServer
        1. 1.1.1.1. IIS-CommonHttpFeatures
        2. 1.1.1.2. IIS-ApplicationDevelopment
        3. 1.1.1.3. IIS-HealthAndDiagnostics
        4. 1.1.1.4. IIS-Security
        5. 1.1.1.5. IIS-Performance
      2. 1.1.2. IIS-WebServerManagementTools
      3. 1.1.3. IIS-FTPPublishingService
      4. 1.1.4. WAS-WindowsActivationService
    2. 1.2. Extensible Architecture of IIS 7
    3. 1.3. IIS 7 and ASP.NET Integrated Request Processing Pipeline
    4. 1.4. IIS 7 and ASP.NET Integrated Configuration Systems
    5. 1.5. IIS 7 and ASP.NET Integrated Administration
    6. 1.6. Building a Customized Web Server
      1. 1.6.1. Update Dependencies
      2. 1.6.2. Windows Features Dialog
      3. 1.6.3. Server Manager
      4. 1.6.4. Command-Line Setup Option
      5. 1.6.5. Unattended Setup Option
      6. 1.6.6. Upgrade
    7. 1.7. Summary
  7. 2. Using the Integrated Configuration System
    1. 2.1. Integrated Configuration System
      1. 2.1.1. Hierarchical Configuration Schema
        1. 2.1.1.1. Section Groups
        2. 2.1.1.2. Configuration Sections
      2. 2.1.2. Distributed Configuration System
      3. 2.1.3. <location> Tags
      4. 2.1.4. Include Files
      5. 2.1.5. <configSections>
    2. 2.2. Protocol Listeners
    3. 2.3. Windows Process Activation Service
    4. 2.4. World Wide Web Publishing Service
    5. 2.5. The Structure of the applicationHost.config File
      1. 2.5.1. <system.applicationHost>
        1. 2.5.1.1. <applicationPools>
          1. 2.5.1.1.1. The managedPipelineMode Attribute
          2. 2.5.1.1.2. The queueLength Attribute
          3. 2.5.1.1.3. The <processModel> Child Element
          4. 2.5.1.1.4. The <recycling> Child Element
          5. 2.5.1.1.5. The <cpu> Child Element
          6. 2.5.1.1.6. <applicationPoolDefaults>
        2. 2.5.1.2. <sites>
      2. 2.5.2. <system.webServer>
        1. 2.5.2.1. <defaultDocument>
        2. 2.5.2.2. <directoryBrowse>
        3. 2.5.2.3. <globalModules>
        4. 2.5.2.4. <handlers>
          1. 2.5.2.4.1. Classic ASP
          2. 2.5.2.4.2. ASP.NET Pages
          3. 2.5.2.4.3. Windows Communications Foundation (WCF)
        5. 2.5.2.5. <modules>
        6. 2.5.2.6. <security>
          1. 2.5.2.6.1. <access>
          2. 2.5.2.6.2. <authentication>
          3. 2.5.2.6.3. <authorization>
    6. 2.6. Summary
  8. 3. Managing the Integrated Configuration System from IIS Manager and the Command Line
    1. 3.1. Server Management
    2. 3.2. Internet Information Services (IIS) Manager
      1. 3.2.1. Application Pools
      2. 3.2.2. Web Sites
      3. 3.2.3. Hierarchical Configuration
      4. 3.2.4. Delegation
    3. 3.3. Command-Line Tool
      1. 3.3.1. LIST
      2. 3.3.2. ADD
      3. 3.3.3. DELETE
      4. 3.3.4. SET
    4. 3.4. Summary
  9. 4. Managing the Integrated Configuration System with Managed Code
    1. 4.1. Class Diagrams
    2. 4.2. ConfigurationElement
    3. 4.3. ConfigurationElementCollectionBase<T>
    4. 4.4. ApplicationPool
      1. 4.4.1. ApplicationPoolProcessModel
      2. 4.4.2. ApplicationPoolRecycling
        1. 4.4.2.1. ApplicationPoolPeriodicRestart
        2. 4.4.2.2. ScheduleCollection
      3. 4.4.3. ApplicationPoolCpu
    5. 4.5. ApplicationPoolCollection
    6. 4.6. Site
      1. 4.6.1. Binding
      2. 4.6.2. BindingCollection
    7. 4.7. Application
    8. 4.8. ApplicationCollection
    9. 4.9. VirtualDirectory
    10. 4.10. VirtualDirectoryCollection
    11. 4.11. ConfigurationSection
    12. 4.12. ServerManager
    13. 4.13. Putting It All Together
      1. 4.13.1. Recipe for Loading a Specified Configuration File
      2. 4.13.2. Recipe for Accessing the Specified Attribute of a Specified Configuration Section
      3. 4.13.3. Recipe for Adding or Removing an Element from the Specified Collection Element of a Specified Configuration Section
      4. 4.13.4. Recipe for Accessing the Configuration Sections in the <system.applicationHost> Section Group
        1. 4.13.4.1. Adding an Application Pool
        2. 4.13.4.2. Adding a Web Site
        3. 4.13.4.3. Adding a Binding
        4. 4.13.4.4. Adding a Web Application
        5. 4.13.4.5. Adding a Virtual Directory
    14. 4.14. Summary
  10. 5. Extending the Integrated Configuration System and Imperative Management API
    1. 5.1. IIS7 and ASP.NET Integrated Configuration Extensibility Model
      1. 5.1.1. IIS7 and ASP.NET Integrated Declarative Schema Extension Markup Language
        1. 5.1.1.1. <sectionSchema>
        2. 5.1.1.2. <attribute>
        3. 5.1.1.3. <element>
        4. 5.1.1.4. <collection>
      2. 5.1.2. Adding a Custom Configuration Section
        1. 5.1.2.1. Machine-Level Configuration File
        2. 5.1.2.2. Site-Level Configuration File
        3. 5.1.2.3. Application-Level Configuration File
    2. 5.2. IIS7 and ASP.NET Integrated Imperative Management Extensibility Model
      1. 5.2.1. Representing the Collection Item
      2. 5.2.2. Representing the Collection Element
      3. 5.2.3. Representing the Non-collection Element
      4. 5.2.4. Representing the Outermost Element
      5. 5.2.5. Putting It All Together
    3. 5.3. Summary
  11. 6. Understanding the Integrated Graphical Management System
    1. 6.1. Module Pages
      1. 6.1.1. ModuleDialogPage
      2. 6.1.2. ModuleListPage
      3. 6.1.3. ModulePropertiesPage
      4. 6.1.4. Writing a Custom Module Page
    2. 6.2. Tasks
      1. 6.2.1. Page Navigation
      2. 6.2.2. Task Forms
      3. 6.2.3. Wizard Forms
    3. 6.3. The IIS7 Manager Object Model
      1. 6.3.1. Service
        1. 6.3.1.1. IServiceProvider
        2. 6.3.1.2. IServiceContainer
      2. 6.3.2. ManagementConfigurationPath
      3. 6.3.3. Connection
      4. 6.3.4. Navigation Item
      5. 6.3.5. Navigation Service
      6. 6.3.6. TaskItem
        1. 6.3.6.1. TextTaskItem
        2. 6.3.6.2. MessageTaskItem
        3. 6.3.6.3. MethodTaskItem
        4. 6.3.6.4. GroupTaskItem
      7. 6.3.7. TaskList
      8. 6.3.8. ModulePageInfo
      9. 6.3.9. TaskListCollection
    4. 6.4. Putting It All Together
    5. 6.5. Summary
  12. 7. Extending the Integrated Graphical Management System
    1. 7.1. Client-Side Managed Code
    2. 7.2. Custom Module Pages and Task Forms in Action
    3. 7.3. Proxies
      1. 7.3.1. ModuleServiceProxy
      2. 7.3.2. What's PropertyBag Anyway?
        1. 7.3.2.1. Constructors
        2. 7.3.2.2. Indexer
        3. 7.3.2.3. ModifiedKeys
        4. 7.3.2.4. GetState
        5. 7.3.2.5. CreatePropertyBagFromState
    4. 7.4. MyConfigSectionPage
      1. 7.4.1. Constructor
      2. 7.4.2. Event Handlers
      3. 7.4.3. HasChanges Property
      4. 7.4.4. CanApplyChanges Property
      5. 7.4.5. OnActivated
      6. 7.4.6. GetSettings
      7. 7.4.7. OnWorkerGetSettings
      8. 7.4.8. OnWorkerGetSettingsCompleted
      9. 7.4.9. MyConfigSectionInfo
      10. 7.4.10. InitializeUI
      11. 7.4.11. ApplyChanges
      12. 7.4.12. GetValues
      13. 7.4.13. CancelChanges
      14. 7.4.14. Adding Support for New Task Items
        1. 7.4.14.1. TaskList
        2. 7.4.14.2. ViewCollectionItems
        3. 7.4.14.3. Tasks
      15. 7.4.15. Refreshing
    5. 7.5. MyCollectionPage
      1. 7.5.1. InitializeListPage
      2. 7.5.2. OnActivated
      3. 7.5.3. GetCollectionItems
      4. 7.5.4. OnWorkerGetCollectionItems
      5. 7.5.5. OnWorkerGetCollectionItemsCompleted
      6. 7.5.6. MyCollectionItemInfo
      7. 7.5.7. MyCollectionItemListViewItem
      8. 7.5.8. AddItem
      9. 7.5.9. Adding Support for New Task Items
        1. 7.5.9.1. Custom Task List
        2. 7.5.9.2. Tasks
        3. 7.5.9.3. UpdateCollectionItemIdentifier
        4. 7.5.9.4. AddCollectionItem
        5. 7.5.9.5. DeleteCollectionItem
        6. 7.5.9.6. UpdateCollectionItem
      10. 7.5.10. OnListViewBeforeLabelEdit
      11. 7.5.11. OnListViewAfterLabelEdit
      12. 7.5.12. OnListViewDoubleClick
      13. 7.5.13. OnListViewKeyUp
      14. 7.5.14. OnListViewSelectedIndexChanged
      15. 7.5.15. Grouping
      16. 7.5.16. Refreshing
    6. 7.6. MyCollectionItemTaskForm
      1. 7.6.1. Constructors
      2. 7.6.2. InitializeComponent
      3. 7.6.3. OnAccept
      4. 7.6.4. OnWorkerDoWork
      5. 7.6.5. OnWorkerCompleted
    7. 7.7. Module
      1. 7.7.1. Module
      2. 7.7.2. MyConfigSectionModule
    8. 7.8. Server-Side Managed Code
      1. 7.8.1. Module Service
        1. 7.8.1.1. GetMyConfigSectionSection
        2. 7.8.1.2. GetSettings
        3. 7.8.1.3. UpdateSettings
        4. 7.8.1.4. GetCollectionItems
        5. 7.8.1.5. AddCollectionItem
        6. 7.8.1.6. DeleteCollectionItem
        7. 7.8.1.7. UpdateCollectionItem
      2. 7.8.2. Module Provider
    9. 7.9. Deployment
    10. 7.10. Summary
  13. 8. Extending the Integrated Request Processing Pipeline
    1. 8.1. Extending the Integrated Pipeline through Managed Code
    2. 8.2. Managed Handlers
      1. 8.2.1. Developing Custom Managed Handlers
        1. 8.2.1.1. IsReusable
        2. 8.2.1.2. Constructor
        3. 8.2.1.3. ProcessRequest
        4. 8.2.1.4. LoadRss
        5. 8.2.1.5. GetDataReader
        6. 8.2.1.6. GenerateRss
      2. 8.2.2. Plugging Custom Managed Handlers into the Integrated Request Processing Pipeline
      3. 8.2.3. Using the RssHandler HTTP Handler
    3. 8.3. Managed Modules
      1. 8.3.1. Developing Custom Managed Modules
      2. 8.3.2. Plugging Custom Managed Modules into the Integrated Request Processing Pipeline
      3. 8.3.3. Using the UrlRewriterModule HTTP Module
    4. 8.4. Managed Handler Factories
      1. 8.4.1. Developing Custom Managed Handler Factories
      2. 8.4.2. Plugging Custom Managed Handler Factories into the Integrated Request Processing Pipeline
    5. 8.5. Extending the Integrated Pipeline with Configurable Managed Components
    6. 8.6. Configuration Support for the URL Rewriting Managed Module
    7. 8.7. Imperative Management Support for the URL Rewriting Managed Module
      1. 8.7.1. UrlRewriterRule
      2. 8.7.2. UrlRewriterRules
      3. 8.7.3. UrlRewriterSection
      4. 8.7.4. Testing the Managed Classes
    8. 8.8. Graphical Management Support for the URL Rewriter Managed Module
    9. 8.9. Client-Side Managed Code
      1. 8.9.1. Communications with the Back-End Server
      2. 8.9.2. UrlRewriterPage
        1. 8.9.2.1. InitializeListPage
        2. 8.9.2.2. OnActivated
        3. 8.9.2.3. GetUrlRewriterSettings
        4. 8.9.2.4. OnWorkerGetUrlRewriterSettings
        5. 8.9.2.5. OnWorkerGetUrlRewriterSettingsCompleted
        6. 8.9.2.6. UrlRewriterRuleInfo
        7. 8.9.2.7. UrlRewriterRuleListViewItem
        8. 8.9.2.8. AddItem
        9. 8.9.2.9. Adding Support for New Task Items
          1. 8.9.2.9.1. PageTaskList
          2. 8.9.2.9.2. Tasks
          3. 8.9.2.9.3. AddUrlRewriterRule
          4. 8.9.2.9.4. DeleteUrlRewriterRule
          5. 8.9.2.9.5. UpdateUrlRewriterRule
        10. 8.9.2.10. OnListViewSelectedIndexChanged
        11. 8.9.2.11. OnListViewDoubleClick
        12. 8.9.2.12. OnListViewKeyUp
      3. 8.9.3. UrlRewriterRuleTaskForm
        1. 8.9.3.1. Constructors
        2. 8.9.3.2. InitializeComponent
        3. 8.9.3.3. OnAccept
        4. 8.9.3.4. OnWorkerDoWork
        5. 8.9.3.5. OnWorkerCompleted
      4. 8.9.4. UrlRewriterModule
    10. 8.10. Server-Side Managed Code
      1. 8.10.1. UrlRewriterModuleService
        1. 8.10.1.1. GetUrlRewriterSection
        2. 8.10.1.2. GetUrlRewriterSettings
        3. 8.10.1.3. AddUrlRewriterRule
        4. 8.10.1.4. DeleteUrlRewriterRule
        5. 8.10.1.5. UpdateUrlRewriterRule
      2. 8.10.2. UrlRewriterModuleProvider
    11. 8.11. Registering UrlRewriterModuleProvider
    12. 8.12. Configurable UrlRewriterModule
    13. 8.13. Rewriting Non-ASP.NET URLs
    14. 8.14. Postback Problem with URL Rewriting
    15. 8.15. Summary
  14. 9. Understanding the Integrated Providers Model
    1. 9.1. Why You Need Provider-Based Services
    2. 9.2. The Integrated Providers Model in Action
    3. 9.3. Under the Hood of the Integrated Providers Model
      1. 9.3.1. ProviderFeature
      2. 9.3.2. ProviderConfigurationSettings
      3. 9.3.3. Putting it All Together
        1. 9.3.3.1. Workflow that Displays the ProviderConfigurationConsolidatedPage Module List Page
        2. 9.3.3.2. Workflow for Viewing the Providers of a Provider-Based Service
        3. 9.3.3.3. Workflow for Adding a New Provider to a Provider-Based Service
        4. 9.3.3.4. Workflow for Updating a Provider of a Provider-Based Service
      4. 9.3.4. IProviderConfigurationService
    4. 9.4. Summary
  15. 10. Extending the Integrated Providers Model
    1. 10.1. Recipe
    2. 10.2. Custom Provider Base Class
    3. 10.3. Custom Provider Collection
    4. 10.4. Extending the Integrated Configuration System
    5. 10.5. Extending the Integrated Imperative Management System
      1. 10.5.1. ProviderSettings
      2. 10.5.2. ProviderSettingsCollection
      3. 10.5.3. ProvidersHelper
      4. 10.5.4. RssSection
    6. 10.6. Implementing the Service Class
    7. 10.7. Implementing Custom Providers
      1. 10.7.1. SqlRssProvider
        1. 10.7.1.1. Initialize
        2. 10.7.1.2. Connection String
        3. 10.7.1.3. Command Text
        4. 10.7.1.4. Command Type
        5. 10.7.1.5. RSS-Related Fields
        6. 10.7.1.6. LoadRss
        7. 10.7.1.7. Registering SqlRssProvider
      2. 10.7.2. XmlRssProvider
        1. 10.7.2.1. Initialize
        2. 10.7.2.2. LoadRss
        3. 10.7.2.3. RetrieveData
        4. 10.7.2.4. Registering XmlRssProvider
    8. 10.8. Extending the Integrated Graphical Management System
      1. 10.8.1. Client-Side Managed Code
        1. 10.8.1.1. Implementing a Custom Provider Configuration Settings Class
        2. 10.8.1.2. Implementing a Custom Provider Feature
        3. 10.8.1.3. Implementing a Custom Section PropertyBag Wrapper Class
        4. 10.8.1.4. Implementing a Custom Module Service Proxy
        5. 10.8.1.5. Implementing a Custom Module Page
          1. 10.8.1.5.1. InitializeComponent
          2. 10.8.1.5.2. OnActivated
          3. 10.8.1.5.3. ApplyChanges
          4. 10.8.1.5.4. CancelChanges
          5. 10.8.1.5.5. PageTaskList
          6. 10.8.1.5.6. EnableRss
          7. 10.8.1.5.7. DisableRss
          8. 10.8.1.5.8. ConfigureRssProvider
          9. 10.8.1.5.9. SetDefaultProvider
          10. 10.8.1.5.10. Tasks
          11. 10.8.1.5.11. ProviderConfigurationService
          12. 10.8.1.5.12. ReadOnly
          13. 10.8.1.5.13. Refreshing
          14. 10.8.1.5.14. RssEnabled
        6. 10.8.1.6. Implementing a Custom Task Form
          1. 10.8.1.6.1. Constructor
          2. 10.8.1.6.2. InitializeComponent
          3. 10.8.1.6.3. GetProviders
          4. 10.8.1.6.4. OnAccept
        7. 10.8.1.7. Implementing a Custom Module
      2. 10.8.2. Server-Side Managed Code
        1. 10.8.2.1. Implementing a Custom Module Service
          1. 10.8.2.1.1. Enabling and Disabling the RSS Service
          2. 10.8.2.1.2. GetProviders
          3. 10.8.2.1.3. GetSettings
          4. 10.8.2.1.4. UpdateChannelSettings
        2. 10.8.2.2. Implementing a Custom Configuration Module Provider
    9. 10.9. Summary
  16. 11. Integrated Tracing and Diagnostics
    1. 11.1. Integrated Tracing Components
    2. 11.2. Tasks Performed from within Your Code
      1. 11.2.1. Instantiating a Trace Source
      2. 11.2.2. Adding Trace Events
        1. 11.2.2.1. TraceEvent
        2. 11.2.2.2. TraceData
        3. 11.2.2.3. TraceInformation
        4. 11.2.2.4. TraceTransfer
      3. 11.2.3. Defining the Conditional Compilation Symbol "TRACE"
    3. 11.3. Tasks Performed from the Configuration File
      1. 11.3.1. Instantiating and Attaching a Switch
        1. 11.3.1.1. Under the Hood of SourceSwitch
        2. 11.3.1.2. Imperatively Instantiating and Attaching a Switch
      2. 11.3.2. Instantiating and Attaching an IisTraceListener
      3. 11.3.3. Instantiating and Attaching a Trace Filter
        1. 11.3.3.1. EventTypeFilter
        2. 11.3.3.2. SourceFilter
    4. 11.4. Putting It All Together
    5. 11.5. Configurable Tracing
    6. 11.6. Runtime Status and Control API
      1. 11.6.1. ServerManager
      2. 11.6.2. WorkerProcessCollection
      3. 11.6.3. WorkerProcess
      4. 11.6.4. RequestCollection
      5. 11.6.5. Request
      6. 11.6.6. ApplicationDomain
      7. 11.6.7. ApplicationDomainCollection
      8. 11.6.8. ApplicationPool
      9. 11.6.9. Site
      10. 11.6.10. Putting It All Together
    7. 11.7. LogRequest
    8. 11.8. Summary
  17. 12. ASP.NET and Windows Communication Foundation Integration in IIS 7
    1. 12.1. Installing the Required Software
    2. 12.2. Bug Report Manager
    3. 12.3. Windows Communication Foundation Service
    4. 12.4. Windows Communication Foundation Endpoint
    5. 12.5. Windows Communication Foundation Service Model
    6. 12.6. Developing a WCF Service
    7. 12.7. Developing a WCF Service Contract
    8. 12.8. Implementing a WCF Service Contract
    9. 12.9. Hosting a WCF Service
    10. 12.10. Administrative Tasks
    11. 12.11. Developing a Windows Communication Foundation Client
      1. 12.11.1. Adding a Web Reference
      2. 12.11.2. Using the svcutil.exe Tool
      3. 12.11.3. Imperative Approach
    12. 12.12. Taking Advantage of ASP.NET and WCF Integration in IIS 7
    13. 12.13. Using Different Bindings
    14. 12.14. Putting It All Together
    15. 12.15. Summary

Product information

  • Title: Professional IIS 7 and ASP.NET Integrated Programming
  • Author(s):
  • Release date: October 2007
  • Publisher(s): Wrox
  • ISBN: 9780470152539