Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http://localhost:port always redirecting to https://localhost

I'm building a simple website in vs2015. I have IIS express selected as the hosting environment. I have tried multiple new projects and seem to be going around in circles, having installed and uninstalled iis-express 10 multiple times, and added and removed windows feature of iis also. When I launch a web project from vs2015, it used to open (without issue) a http://localhost:port (e.g. http://localhost:51898), but now continually redirects to https://localhost.

Any idea why?

like image 500
nealkernohan Avatar asked Jul 26 '17 18:07

nealkernohan


People also ask

Why does HTTP change automatically to HTTPS?

HSTS is a security feature that forces the browser to use HTTPS even when accessing an HTTP URL. The browser will start using HSTS for a domain after receiving a Strict-Transport-Security header from the server. The browser also ships with a list of domains for which HSTS is enabled by default.


2 Answers

It is not about Visual Studio, it is about Chrome. This solution worked for me: Google Chrome redirecting localhost to https

like image 165
Sergey Avatar answered Nov 06 '22 06:11

Sergey


the redirect will only happen with explict configuration and IIS or asp.net will not automatically redirect .

  • check following config files and loo for any redirect settings
    • ApplicationHost.Config,All web.config files (C:\Windows\System32\inetsrv\config) search for httpRedirect

e.g. <httpRedirect enabled="true" destination="https://localhost" />

  • check for urlrewrite configurations. a typical rule will be like this .so you can search for Redirect

                <action type="Redirect" url="http://www.maindomain.com/{R:1}" />
            </rule>
    
    • If you do not find these settings anywhere in your configuration,your application code is doing this.Check your code
like image 37
Rohith Avatar answered Nov 06 '22 06:11

Rohith