Chapter 4. Managing the Integrated Configuration System with Managed Code

The previous chapters walked you through the XML structure of the IIS7 and ASP.NET integrated configuration system. You learned a great deal about the XML elements and attributes that make up this system. You also learned how to use the IIS7 Manager and APPCMD command-line tool to indirectly manipulate these XML elements and attributes.

There are times when you want to manipulate these XML elements and attributes from your C# or Visual Basic code. Obviously, GUI-based and command-line–based approaches such as the IIS7 Manager and the APPCMD tool won't help you with this.

The managed classes of the new Microsoft.Web.Administration namespace together form an API that allows you to treat the XML elements and attributes of the IIS7 and ASP.NET integrated configuration system as managed objects, which means you can use object-oriented managed code to manipulate them.

Class Diagrams

To help you understand the managed classes in the Microsoft.Web.Administration namespace, let's revisit the XML elements and attributes used in the <applicationHost> section group of the applicationHost.config file as shown in Listing 4-1. Recall that this file contains the IIS7-specific configuration sections. Because we're only interested in the XML elements and attributes themselves, I've left out the attribute values from Listing 4-1.

Example 4.1. The applicationHost.config File

<configuration> <applicationHost> <applicationPools> <add ...

Get Professional IIS 7 and ASP.NET Integrated Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.