2

I want to know how many ISAPI filters are active on IIS. And I also want to read the metadata properties of these active ISAPI filters in C#.

I have created an ISAPI filter dll and added it to IIS. I can see that filter in "inetmgr" but I want to get the same information through C#. Is that possible?

DanM7
  • 2,203
  • 3
  • 28
  • 46
Sandy
  • 6,285
  • 15
  • 65
  • 93

1 Answers1

2

You can use ADSI

The path is "IIS://LocalHost/W3SVC/Filters"

http://msdn.microsoft.com/en-us/library/ms525344(VS.90).aspx

And you can get access to that in c# using DirectoryEntry 's

http://support.microsoft.com/kb/315716

DirectoryEntry de = new DirectoryEntry("IIS://LocalHost/W3SVC/Filters");
foreach (DirectoryEntry child in de.Children) {
 child.Name
 child.Properties["SomeProperty"].Value
}
djeeg
  • 6,685
  • 3
  • 25
  • 28
  • Thanks for reply. I have created a ISAPI filter dll and added with IIS. I can see that filter in inetmgr but I am unable to get the information about the same. – Sandy Jan 17 '11 at 09:05
  • is it assigned to all sites, or one particular site? you might have to look at the site's filter "IIS://LocalHost/W3SVC/%websiteid%/Filters" – djeeg Jan 17 '11 at 09:08
  • Its giving n error: foreach statement cannot operate on variables of type 'System.DirectoryServices.DirectoryEntry' because 'System.DirectoryServices.DirectoryEntry' does not contain a public definition for 'GetEnumerator' – Sandy Jan 17 '11 at 09:42
  • Yes i had updated it Its giving only count 5 that doesn't contains my ISAPI filter. – Sandy Jan 17 '11 at 09:49
  • I am doing this:private void button1_Click(object sender, EventArgs e) { DirectoryEntry de = new DirectoryEntry("IIS://localhost/W3SVC/Filters"); foreach (DirectoryEntry child in de.Children) { label1.Text = string.Concat(child.Name, "+" ,child.Properties["Status"].Value); } } – Sandy Jan 17 '11 at 09:57