In IIS 7.0, you can use one the following 4 ways to configure the IIS 7.0 settings configuration system:
- IIS 7.0 Manager tool.
- appcmd.exe command-line tool.
- Microsoft.Web.Administration managed API.
- Manual editing for the ApplicationHost.config file.
In this post I will introduce the Microsoft.Web.Administration API. The IIS 7.0 team thought of the developers and provided this managed API that allows you to access the configuration system of the IIS 7.0. The API get loaded into the machince once you install IIS and it is located at: %SystemDrive%\Windows\System32\Inetsrv\.
The major object in the API is the ServerManager class. It is a factory class that contains several important properties like the Sites, ApplicationPools, VirtualDirectories, etc .... For example, to create a new website on II 7.0, you can write the following:
// Get a reference to the factory object
var manager = new ServerManager();
// Define a new website
// Commit changes to the ApplicationHost.config
For a more detailed reference on the API, you can check the following article How to Use Microsoft.Web.Administration (http://learn.iis.net/page.aspx/165/how-to-use-microsoftwebadministration/)
Hope this helps,