Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Introducing Internet Information Services (IIS) 7.0 : Page 3

Find out what Microsoft has changed and added in its newest web server, and how you can capitalize on the new features and architecture.


advertisement
Exploring the Runtime State and Control API
Microsoft ships a new managed API called the Runtime State and Control API (RSCA)) that provides access to runtime information from an IIS-based web server. This API provides information about the different IIS worker processes that are currently running. The API not only lets you gather state information from running processes, it also allows you to modify the state of those processes.

To use the Runtime and State and Control API you need to add a reference to the Microsoft.Web.Administration.dll file, which you'll find on your installation drive in the Windows\System32\inetsrv folder. Figure 8 shows the hierarchy of classes in the Microsoft.Web.Administration namespace.

 
Figure 8. Class Hierarchy: The figure shows the class hierarchy in the Microsoft.Web.Administration namespace.
At the top of the hierarchy is the ServerManager class. The ServerManager class can be used to access the three important aspects related to IIS—the WorkerProcess, the Site, and the ApplicationPool. An instance of ServerManager would hold collections of each of these.

The Sites collection shown in Figure 8 represents the web sites in IIS. It is possible to create new sites as well as iterate through web sites using the object model. The code snippet below illustrates how to create a new web site:

//Create a New Site ServerManager objServerManager = new ServerManager(); objServerManager.Sites.Add("MyNewSite", @"C:\inetpub\wwwroot\MyNewSite", 101); objServerManager.CommitChanges();

The next snippet demonstrates how to iterate through all the web sites, starting any web site not already running:

//Iterate through all Sites foreach (Site objSite in objServerManager.Sites) { string strName = objSite.Name; string strState = objSite.State.ToString(); if (objSite.State != ObjectState.Started) objSite.Start(); }

You use the WorkerProcesses collection to obtain a reference to any worker process running on the server. For example, to iterate through all the worker processes on a server and display the ProcessId and State properties of each worker process, you'd write code like this:



//Iterate through all Workerprocesses ServerManager objServerManager = new ServerManager(); foreach(WorkerProcess objWorkerProcess in objServerManager.WorkerProcesses) { string strProcessId = objWorkerProcess.ProcessId.ToString(); string strState = objWorkerProcess.State.ToString(); }

The WorkerProcess can also be used to examine the requests that have been processed by a web server. The code snippet below demonstrates the usage of the API to view the requests.

WorkerProcess objWorkerProcess = objServerManager.WorkerProcesses[0]; RequestCollection objRequests = objWorkerProcess.GetRequests(0); foreach (Request objRequest in objRequests) { MessageBox.Show(objRequest.Verb); MessageBox.Show(objRequest.ClientIPAddr); MessageBox.Show(objRequest.Url); }

Finally, you use the ApplicationPools collection to access the application pools on a server. Again, you can iterate through the pools to perform various operations, such as recycling a pool. The code snippet below iterates through the AppplicationPools collection and recycles each application pool.

foreach (ApplicationPool objApplicationPool in objServerManager.ApplicationPools) { string strPoolName = objApplicationPool.Name; string strPoolState = objApplicationPool.State.ToString(); objApplicationPool.Recycle(); }

You can download the IIS 7 Managed Module Starter Kit to get a project template and a guide to help you through your first development project.

Performance Improvements
IIS 7.0 sports performance gains due to improvements in HTTP.sys and because of the Longhorn Networking and file system improvements. Because IIS 7.0 and its corresponding server operating system (Windows Longhorn Server) are still in beta, there are no real-world benchmarks available to provide a more in-depth performance comparison or analysis. Nevertheless, the improvements and optimizations made should result in performance gains.

IIS 7.0 and Windows Editions
IIS 7.0 is available on Windows Vista and will of course be available on Windows Server "Longhorn" Operating Systems as well. Because Windows Vista is a client operating system, there are limitations imposed on IIS on that OS, including simultaneous request execution limit as well as other feature limitations. Only Windows Vista Professional (Professional Edition corresponds to Vista Enterprise, Business, and Ultimate Editions) supports all the IIS features found on the Server Edition, and even that version has a limit of no more than seven simultaneous requests.



Vikram Srivatsa is a technology consultant within HP Services at Hewlett-Packard, and is based out of Bangalore, India.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap