In my ASP.NET web app I’d like to look up the name it was given when it was created in IIS, which is unique to the server. I’d not interested in the domain name for the web site but the actual name given to the site in IIS.
I need to be able to do it reliably for IIS6 and 7.
To be clear I’m talking about the given name in IIS, not the domain name and not the virtual directory path.
Update
As Carlos and others mentioned in the comments, it’s better to use
HostingEnvironment.SiteNamesinceGetSiteNameis not supposed to be used by users (According to the docs).Old Solution