Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you list all the web sites (not applications) being hosted by an IIS server?

Tags:

c#

iis

I'm using IIS 6 on Windows Server 2003. The vision is to create a directory of those applications, showing their urls (ports on Server) and names.

like image 232
Irwin Avatar asked Nov 24 '25 22:11

Irwin


1 Answers

I haven't done it, but I believe you need to use the following WMI object:

DirectoryEntry w3svc = new DirectoryEntry(string.Format("IIS://{0}/w3svc", serverName));
foreach (DirectoryEntry site in w3svc.Children)
{
     //these are the web sites, lookup their properties to see how to extract url
}
like image 101
Grzenio Avatar answered Nov 26 '25 12:11

Grzenio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!