IIS API

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

How do I programmatically list/enumerate the web sites in IIS from a c#
application?

I want to know which host headers each site responds to.
And I suppose there's other useful, per-site, info I also could use, total
size on disk, which framework they execute under, and such stuff.
 
re:
!> How do I programmatically list/enumerate the web sites in IIS from a c# application?

Call a WScript from your C# app...

Set IISOBJ = getObject("IIS://LocalHost/W3SVC")
For each Object in IISOBJ
if (Object.Class = "IIsWebServer") then
WScript.Echo "WWW Site: " & Object.Name & " - " & Object.ServerComment
end if
next

For a "pure" C# script which does what you want to do, see :

http://www.iisfaq.com/Default.aspx?tabid=3166

You could also, if you only have ASP.NET websites, call :

aspnet_regiis -lk

That will list all ASP.NET websites on the server.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Back
Top