IIS 7 and Above
Determining The Default HTTP Port
Last post May 25, 2012 08:26 PM by email@example.com
May 24, 2012 06:03 PM|geomar|LINK
I am using ASP.NET 3.5SP1 and IIS 7.5 with a IIS Self Signed Certificate. The Self Signed Certificate uses the MachineName as the url authority.
Some pages are under the HTTP scheme and some are under HTTPS scheme. The scheme changes need to occur programmatically. In other words, I need to be able to programmatically change a scheme from HTTPS to HTTP.
The default HTTP port can differ between Environments(DEV,QA,STAGING,LIVE). I am looking for a way to programmatically determine the default HTTP port used in each environment. So that if the default HTTP port is not 80, I can set it appropriately when moving
from HTTPS back to HTTP. If the port is not set correctly, the page cannot be displayed.
Any suggestions on how to do this?
Maybe I need to be taking a different approach. Your advise is welcome.
May 24, 2012 09:13 PMfirstname.lastname@example.org|LINK
I would think a much smarter choice would be to use port 80 for all installations. You'll run into other issues with non-standard ports as well. Use a separate IP for each site to make this easy, especially since you're likely using internal IP's for
May 24, 2012 11:05 PM|nastymatt|LINK
May 25, 2012 08:26 PMemail@example.com|LINK
I'm still not sure why you use different ports, but you could always grab the server variables to see: