Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get IIS bindings at runtime

I wonder how to get the IIS binding settings of the current site (host name, port, IP address) at runtime using ASP.NET. Does .NET provide any way to get these information?

Edit: I need a way to get the http and https ports configured to redirect to the right port when switching from http to https, and back from https to http if other ports then 80/443 are used. Is there a way to do this without extended privileges?

Regards

like image 957
Jay Avatar asked Jan 21 '11 20:01

Jay


1 Answers

The only way to achieve that (without being an administrator) is using Microsoft.Web.Administration. I just wrote a quick blog on how to do that, see:
http://blogs.msdn.com/b/carlosag/archive/2011/01/21/get-iis-bindings-at-runtime-without-being-an-administrator.aspx

Basically since IIS has a feature we call Worker Process isolation it is possible to read the configuration from an Application itself without the need of being administrator. If you use ADSI, Metabase, or any other way, you will require being an administrator.

like image 179
Carlos Aguilar Mares Avatar answered Sep 21 '22 18:09

Carlos Aguilar Mares