0

I'm building a small site to deploy locally that I'd like to use to list and link to all the other web applications I have installed locally.

Here's some quick test code that accomplishes something similar to what I'm trying to achieve, but can only get the names of the applications not the address to access them from a browser.

using System;
using Microsoft.Web.Administration;

namespace IISListerTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var iisManager = new ServerManager();
            SiteCollection sites = iisManager.Sites;

            foreach (Site site in sites)
            {
                foreach (Application app in site.Applications)
                {
                    Console.WriteLine(app.Path);
                }
            }
        }
    }
}
mason
  • 31,774
  • 10
  • 77
  • 121
Cryptex
  • 11
  • Did you look at the documentation for the Site class? It has a Bindings property, which returns a BindingCollection object (contains [Binding](https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.administration.binding?view=iis-dotnet) objects). I've not worked with this library, but I was able to find the information you seek in less than a minute thanks to a Google search. Make sure you adequately research your question *before* posting. – mason Jan 30 '20 at 16:02
  • @mason actually this guy might have done that. Microsoft's API sadly doesn't provide that functionality, so people have to write extra code, and for that I linked an existing thread. – Lex Li Jan 30 '20 at 16:25
  • @LexLi Eh, I think that looking at the documentation would have gotten someone close enough with the bindings to construct the proper URL. But good duplicate, as it contains some nice alternatives. – mason Jan 30 '20 at 16:28

0 Answers0