I am trying to get The port which an app is running on, from IIS Express.
So far i tried those two approaches:
//first
var iisExpress = new DirectoryEntry("IIS://localhost/W3SVC/AppPools").Children;
//second
var mgr = new ServerManager().Sites;
But both give me only the DefaultAppPool with the Default Web App, while what i need is the apps i'm running localy from Visual Studio.
This will output the names and ports of all your websites running on IIS.
If you want to save the port of a specific site (ex: MyWebsite) on a variable you can do the following: