62

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?

Zapnologica
  • 22,170
  • 44
  • 158
  • 253

5 Answers5

124

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.

SlimsGhost
  • 2,849
  • 1
  • 10
  • 16
BigJump
  • 15,561
  • 3
  • 31
  • 29
  • But what if it's not in the list when querying? :( – Jag Oct 22 '15 at 10:24
  • 1
    @jag then it's likely not to be HSTS, but something else as some of the other answers refer to. eg. RequireHttps attribute on Controller or a cached redirect. – BigJump Oct 23 '15 at 10:50
29

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

Adam Martin
  • 436
  • 4
  • 6
  • 1
    Yes! After removing HSTS code in web.config, Chrome continued redirecting to HTTPS unless cache was cleared. Thank you very much!! – Shiva Naru Jun 10 '17 at 01:01
  • 1
    This did the trick for me, too. It's weird, though. I didn't expect this to be a caching-issue since I haven't had any issues when switching from http to https. +1 – Alan Oct 11 '17 at 21:08
10

Remove [RequireHttps] attribute above HomeController.

stink
  • 865
  • 8
  • 19
Dmitry Stepanov
  • 2,776
  • 8
  • 29
  • 45
7

Try clearing your browser cache if all else fails. I tried every solution noted above - perhaps they helped, but visibly everything returned to normal after clearing my browser cache.

mbuchok
  • 391
  • 6
  • 18
  • 1
    This worked for me! The project had been run once in Release, which forced HTTPS. After that, Chrome always did the redirect. Clearing the cache fixed the issue. – Synesthetic Symphony Jun 12 '19 at 20:41
1

I had a redirect in the web config, even after changing this it was still redirecting. Deleting the .csproj.user file fixed the issue for me.

Mick
  • 6,527
  • 4
  • 52
  • 67