Not sure if this is what you re after, but I recently had to get the URL of the default website on IIS. It proved to be a real pain, but I managed to get this working code...
using System.DirectoryServices;
using System.Diagnostics;
private string GetDefaultSite()
{
using (DirectoryEntry w3svc2 = new DirectoryEntry("IIS://Localhost/W3SVC"))
{
foreach (DirectoryEntry de in w3svc2.Children)
{
if (de.SchemaClassName == "IIsWebServer" &&
de.Properties["ServerComment"].Value.ToString() == "Default Web Site")
{
string binding = de.Properties["ServerBindings"].Value.ToString();
string[] split = binding.Split( : );
if (split[2] == "") return "http://localhost/";
else return "http://" + split[2] + "/";
}
}
}
return "";
}