How to use Microsoft.Web.Administration.dll to get the site information the page is running on?
Posted
by Keith Barrows
on Stack Overflow
See other posts from Stack Overflow
or by Keith Barrows
Published on 2010-06-11T21:46:21Z
Indexed on
2010/06/12
4:52 UTC
Read the original article
Hit count: 620
I have a half dozen sites on my server and I would like to get some info from IIS7 to display in the footer of each page (as long as you are an admin of course). I am going through the ServerObject and found Sites but am not finding anything obvious for "this site". What should I do to get at the information for the exact site in IIS7 that the page is running on?
For a quick 'hack' style approach I wrote this on my default.aspx page code 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
© Stack Overflow or respective owner