Hi,
How can I get the list of Web Services hosted on IIS using ASP.Net. Extensions like .asmx and .svc etc., . want to get these services as a list. We can get collection of Windows services using ServiceController. As like this i need to get Web services hosted on IIS.
Thanks
Sreeenath
Sreenath GPosted Jun 9, 2011, 6:17 AM
I have tried this and even this link..
http://stackoverflow.com/questions/1731794/asp-net-iis-metabase-doesnt-return-all-sites
but I am getting either acces problem or other...not getting clear picture on this.
Jaganathan BantheswaranPosted Jun 7, 2011, 1:41 PM
Yes... I have posted this question on stackoverflow on 06-06-2011. Because i dont know the ans for this question & i wanted to know. But there also i didnt get the exact ans.
I got it now. But here what you have answered is simply we are getting the service names as string collection [files names]. Is there any property/method to get the Service Collection so that we can do some thing on that collection items ? Is it possible using that IIS SDK ?.
Suthish NairPosted Jun 7, 2011, 6:22 AM
Its seems you have posted the same question on stackoverflow?
http://stackoverflow.com/questions/6248506/how-to-get-all-web-services-hosted-in-iis-using-c
Sreenath,
You need to do some thing like below..
Add reference using System.DirectoryServices;
DirectoryEntry iISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/Root");
foreach (var item1 in iISAdmin.Children)
{
foreach (var item2 in ((DirectoryEntry)(item1)).Properties)
{
if (((PropertyValueCollection)(item2)).PropertyName.ToString() == "DefaultDoc")
{
if (((PropertyValueCollection)(item2)).Value != null)
{
if (((PropertyValueCollection)(item2)).Value.ToString().Contains(".asmx"))
{
Response.Write("Property Name:" + ((PropertyValueCollection)(item2)).PropertyName.ToString() + "
");
Response.Write("Property Value:" + ((PropertyValueCollection)(item2)).Value.ToString() + "
");
}
}
}
}
}
Jaganathan BantheswaranPosted Jun 7, 2011, 3:34 AM
For your query, you need to install IIS SDK to access the IIS via C#.
For more details visit here