Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio website is redirecting http to https when debugging

I am having an issue with IIS express or Visual Studio 2013.

The site has NO https or ssl enabled or setup in the properties.

When I click debug, the site launches in the broswer and tries to load: http://localhost:61488/Default.aspx

it then for some reason gets automatically redirected to: https://localhost:61488/Default.aspx and I then get an Error code: ERR_SSL_PROTOCOL_ERROR in chrome

Im not quite sure what to do?

like image 750
Zapnologica Avatar asked Oct 22 '14 06:10

Zapnologica


People also ask

How do I enable debugging in Visual Studio?

In the Visual Studio toolbar, make sure the configuration is set to Debug. To start debugging, select the profile name in the toolbar, such as <project profile name>, IIS Express, or <IIS profile name> in the toolbar, select Start Debugging from the Debug menu, or press F5.


2 Answers

I believe this is caused by HSTS - see http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security

If you have (developed) any other localhost sites which send a HSTS header...

eg. Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

...then depending on the value of max-age, future requests to localhost will be required to be served over HTTPS.

To get around this, I did the following.

  • In the Chrome address bar type "chrome://net-internals/#hsts"
  • At the very bottom of a page is QUERY domain textbox - verify that localhost is known to the browser
  • If it is, DELETE the localhost domain using the textbox above
  • Your site should now work using plain old HTTP

This is not a permanent solution, but will at least get it working between projects. If anyone knows how to permanently exclude localhost from the HSTS list please let me know :)

Update - as pointed out in an answer below, you will likely need to clear the browser cache after performing the step above to get the browser to completely "forget" the HSTS info for localhost.

like image 143
BigJump Avatar answered Oct 04 '22 03:10

BigJump


One problem that I ran into that is similar. I ran a HTTPS redirect, then after confirming it works via localhost, I took it out. After running the program again it continued to redirect my localhost. I then cleared my cache on the Chrome browser that VS was running. Everything went back to normal. ~ Visual Studios 2017

like image 26
Adam Martin Avatar answered Oct 04 '22 04:10

Adam Martin