As my love on IIS increases, and to make myself ready for IIS7, I want to try my hands on the programming aspect in IIS7. I personally felt that the best way to start is by writing a simple UI module in IIS7. I am not going to post more about what is a UI module and its advantages, because enough is discussed in IIS.net. Following are some links which will give you enough information about IIS7 UI modules:

What my iis7AddonUI does add to the available UI of IIS7 manager? As you all know IIS7 has an inbuilt FREB module which does the Failed Request tracing. Read more about FREB here http://www.iis.net/default.aspx?tabid=2&subtabid=25&i=969&p=1. In a nutshell, it is similar to ETW tracing. It is now in-built (optional) functionality of IIS7. This will create XML files which will be stored in C:\Inetpub\logs\FailedReqLogFiles\W3SVC*. * - website identifier. My module will give an UI interface to display all available files with their name, path, URL and status code. I also wanted to add the time-taken field which will be helpful in sorting the long running requests and its corresponding status-code later to this UI module.

This UI module also has a iisRequests tab which will display the current running requests. A GUI alternative to appcmd.exe (only for listing the current no. of w3wp.exe running, no. of AppDomains, no. of Clients connected and their details).

I made use of Microsoft.Web.Administration.dll to get the currently running requests and their details. Following is the code snippet which adds all the details of the current requests into a RichTextBox user control.

private void button2_Click(object sender, EventArgs e)

{

            richTextBox2.Clear();

            ServerManager manager = new ServerManager();

            richTextBox2.AppendText("No of running worker processes " + manager.WorkerProcesses.Count + "\n\n");

            foreach (WorkerProcess proc in manager.WorkerProcesses)

            {

                richTextBox2.AppendText("AppPool Name \t" + proc.AppPoolName);

                richTextBox2.AppendText("\nProcessGuid \t\t" + proc.ProcessGuid);

                richTextBox2.AppendText("\nProcessId \t\t" + proc.ProcessId);

                richTextBox2.AppendText("\nState \t\t\t" + proc.State);

                ApplicationDomainCollection a = proc.ApplicationDomains;

                richTextBox2.AppendText("\nAppDomains \t\t" + a.Count);

                foreach (ApplicationDomain ad in a)

                {

                    richTextBox2.AppendText("\n\n\tID \t" + ad.Id);

                    richTextBox2.AppendText("\n\tIdle \t" + ad.Idle);

                    richTextBox2.AppendText("\n\tPhysicalPath \t" + ad.PhysicalPath);

                    richTextBox2.AppendText("\n\tVirtualPath \t" + ad.VirtualPath);

                    richTextBox2.AppendText("\n\t- - - - - - - - - - - - - - - - - - - \n");

                }

                RequestCollection r = proc.GetRequests(0);

                richTextBox2.AppendText("\n\nThere are " + r.Count.ToString() + " requests currently.");

                foreach (Request rq in r)

                {

                    richTextBox2.AppendText("\n\n\tClientIPAddr \t" + rq.ClientIPAddr);

                    richTextBox2.AppendText("\n\tConnectionId \t" + rq.ConnectionId);

                    richTextBox2.AppendText("\n\tCurrentModule \t" + rq.CurrentModule);

                    richTextBox2.AppendText("\n\tHostName \t" + rq.HostName);

                    richTextBox2.AppendText("\n\tLocalIPAddress \t" + rq.LocalIPAddress);

                    richTextBox2.AppendText("\n\tLocalPort \t" + rq.LocalPort);

                    richTextBox2.AppendText("\n\tPipelineState \t" + rq.PipelineState);

                    richTextBox2.AppendText("\n\tRequestId \t" + rq.RequestId);

                    richTextBox2.AppendText("\n\tSiteId \t" + rq.SiteId);

                    richTextBox2.AppendText("\n\tTimeElapsed \t" + rq.TimeElapsed);

                    richTextBox2.AppendText("\n\tTimeInModule \t" + rq.TimeInModule);

                    richTextBox2.AppendText("\n\tTimeInState \t" + rq.TimeInState);

                    richTextBox2.AppendText("\n\tUrl \t" + rq.Url);

                    richTextBox2.AppendText("\n\tVerb \t" + rq.Verb);

                    richTextBox2.AppendText("\n\t- - - - - - - - - - - - - - - - - - - \n");

                }

                richTextBox2.AppendText("\n=========================================\n\n");

            }

Also has a built-in web browser component allow the administrators to browse internet inside inetmgr itself. I’ve pre-added a list of website which will be useful to a web administrator such as support.microsoft.com, iis.net and asp.net.

 

To add this module in your IIS 7 manager follow the below steps:

1.    Save the FREBUI.dll in the inetsrv folder.

2.    From inetsrv folder Drag and Drop the ExtensibilityDemo.dll into the Global Assembly Cache (C:\Windows\assembly).

3.    Under File Menu, browse for the file \Windows\System32\InetSrv\config\Administration.config.

4.    Search for the <moduleProviders> section and add the following

<add name="FREBUI" type="FREBUI.MyModuleProvider, FREBUI,  Version=1.0.0.0, Culture=neutral, PublicKeyToken=263cc0ac07d7d4b6" />

5.    Search for the <modules> section and add the following

<add name="FREBUI" />

6.    Open Inetmgr and You will see the module listed in your IIS 7 Manager if you would’ve followed the above steps properly.

I have attached the FREBUI.Zip with this post, download and extract the FREBUI.dll.