I would like to retrieve the bindings of a running IIS application directly from the context of the applications running code.
I've explored System.Web.Hosting.HostingEnvironment, but from there I can only access properties like SiteName etc.
What I need is the host string part of the binding. Like "app.mydomain.com".
Is that possible? A simple "Yes" or "No" with a msdn reference will suffice as an answer.
You might not be able to get to bindings from IIS config unless you're elevated (and you shouldn't run elevated) but you should be able to get the host part of the binding from:
Request.ServerVariables["URL"];
From there you can load it into the URI class and get the host portion.
Be aware however that it's the url that the request came in on. If you have multiple bindings in the IIS config you won't get those.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With