I have half a dozen sites on my server, and I would like to get some information from IIS7 to display in the footer of each page (while you, of course, are the administrator). I look through ServerObject and find sites, but have not found anything obvious for "this site". What should I do to get information for the exact site in IIS7 the page is running on?
For a quick “crack” style approach, I wrote this on my default.aspx file behind:
ServerManager serverMgr = new ServerManager();
foreach (Site site in serverMgr.Sites)
{
string s = info.Text + site.Name + @"<br/>";
info.Text = s;
foreach (Binding binding in site.Bindings)
{
string t = info.Text + binding.BindingInformation + " | ";
string p = t + binding.Protocol + @"<br/>";
info.Text = p;
}
}
TIA
source
share