Visual Studio 网站在调试时将 http 重定向到 https [英] Visual Studio website is redirecting http to https when debugging

查看:40
本文介绍了Visual Studio 网站在调试时将 http 重定向到 https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 IIS express 或 Visual Studio 2013 时遇到问题.

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

该站点没有在属性中启用或设置 https 或 ssl.

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

当我单击调试时,站点在浏览器中启动并尝试加载:http://localhost:61488/Default.aspx

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

然后由于某种原因被自动重定向到:https://localhost:61488/Default.aspx然后我在 chrome 中得到一个 Error code: ERR_SSL_PROTOCOL_ERROR

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

我不太确定该怎么做?

推荐答案

我相信这是由 HSTS 引起的 - 请参阅 http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security

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

如果您有(开发)任何其他发送 HSTS 标头的本地主机站点...

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

例如.严格传输安全:max-age=31536000;包括子域;预加载

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

...然后根据 max-age 的值,未来对 localhost 的请求将需要通过 HTTPS 提供服务.

...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.

  • 在 Chrome 地址栏中输入chrome://net-internals/#hsts"
  • 页面最底部是 QUERY domain 文本框 - 验证浏览器是否知道 localhost
  • 如果是,请使用上面的文本框删除本地主机域
  • 您的网站现在应该可以使用普通的旧 HTTP

这不是一个永久性的解决方案,但至少可以让它在项目之间工作.如果有人知道如何从 HSTS 列表中永久排除 localhost,请告诉我:)

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 :)

更新 - 正如下面的答案中所指出的,您可能需要<执行上述步骤后,强>清除浏览器缓存,让浏览器完全忘记"本地主机的 HSTS 信息.

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.

这篇关于Visual Studio 网站在调试时将 http 重定向到 https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆