MSDN Magazine Launch Issue - February 15, 2008 - (Page 48) that looks like Figure 4. This class simply wraps the underlying ConfigurationSection class, and provides strongly typed properties to access the underlying configuration data. As you can see from the implementation of the The server-side service is Enabled property, wraploaded inside IIS Manager ping the configuration for local management attributes is straightforward. Wrapping child elescenarios or inside the ments and child collections Web Management requires further impleService in remote mentation of wrapper management scenarios. classes that inherit from ConfigurationElement and ConfigurationCollection respectively (not shown), in a similar fashion to the section wrapper itself. After the wrapper class has been generated, you can compile it into a separate assembly and reference it in your module project or simply add it as a source code file. This will enable the module to access the configuration section in a type-safe way: ResponseModificationSection section = (ResponseModificationSection)WebConfigurationManager.GetSection( context, “responseModification”, typeof(ResponseModificationSection) ); bool enabled = section.Enabled; Kanwaljeet Singla, a fellow IIS team member, located at blogs.iis.net/ ksingla/archive/2006/12/04/tool-to-generate-strongly-typed-classes-for-configuration-sections.aspx. This will generate a wrapper class for the section cally build the wrapper classes from the configuration schema file each time you compile the project. This makes managing changes to the configuration section schema a breeze. Extending IIS Manager Likewise, you can also begin to access the response modification rule collection and the properties on each of the rule elements in a type-safe manner. This makes it a lot easier to program against configuration sections and minimizes the amount of type safety mistakes that are common with weakly typed data access. Also, because all of the code used to access the underlying data is generated automatically by the tool, you can set up Visual Studio to automatiFigure 5 Module Provider Class public sealed class ResponseModificationModuleProvider : ConfigurationModuleProvider { public override Type ServiceType { get { return typeof(ResponseModificationModuleService); } } public override ModuleDefinition GetModuleDefinition(IManagementContext context) { return new ModuleDefinition(Name, “Mvolo.ResponseModification.UI.Client.ResponseModificationModule,”+ “Mvolo.ResponseModificationUI.Client,” + “Version=1.0.0.0, Culture=neutral,” + “PublicKeyToken=309ac0e1b5482072”); } protected override string ConfigurationSectionName { get { return “responseModification”; } } So far, I have shown you how to create the Response Modification module and enable it to read the custom configuration section that controls its behavior. This configuration can be stored in the same configuration files as the rest of IIS configuration information, can be deployed together with the application in web.config files, and can be managed with a variety of tools and APIs including AppCmd.exe and Microsoft.Web.Administration. At this point, the Response Modification module can be deployed and properly configured in any IIS environment. However, you can take it one step further by providing a custom management experience for the IIS Manager console. Doing this brings a number of benefits. It allows system administrators to easily configure the module by using the IIS Manager console, without needing to edit configuration files directly or use any of the lower-level tools and APIs. It also allows the module configuration information to be managed using IIS Manager remote administration capabilities, which take advantage of the Web Management Service (WmSvc). Unlike other tools that also support remote administration, the IIS Manager remote administration architecture offers several key advantages. First, it allows users who are not Administrators on the server to manage sites and applications over which they have control. Second, the IIS Manager remoting mechanism uses HTTPS, instead of DCOM, which is easier to expose through corporate firewalls. Together, these two capabilities make the IIS Manager attractive for delegated remote management of IIS Web sites, especially in shared Web-hosting environments. In the true spirit of IIS 7.0, the IIS Manager provides an extensible architecture on which most of the built-in IIS Manager features are based. To facilitate the remote management scenario, each management feature consists of two parts: the client-side components that provide the UI experience inside IIS Manager, and the server-side component that provides the actual management services. The server-side service is loaded inside IIS Manager for local management scenarios or inside the Web Management Service in remote management scenarios. In the latter case, IIS Manager handles the required communication between the components in IIS Manager on the client machine and the service running inside WmSvc on the target server machine. Creating the Service } The client and server components are typically implemented in two separate .NET assemblies that do not reference each other. All communication between the client and server components is done via the IIS Manager ModuleServiceProxy abstraction that uses weakly typed property bags and basic .NET types to exchange the required information. The server assembly usually contains an implementation of the Microsoft.Web.Management.Server.ModuleProvider class, which performs the necessary registration of services and client-side 48 msdnmagazine IIS 7.0 http://blogs.iis.net/ksingla/archive/2006/12/04/tool-to-generate-strongly-typed-classes-for-configuration-sections.aspx http://blogs.iis.net/ksingla/archive/2006/12/04/tool-to-generate-strongly-typed-classes-for-configuration-sections.aspx http://blogs.iis.net/ksingla/archive/2006/12/04/tool-to-generate-strongly-typed-classes-for-configuration-sections.aspx
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.