当我调试Visual Studio项目使用Chrome浏览器尝试重定向到https相当于我的web地址。我没有在web项目中启用SSL,并且开始URL是http URL。当我使用FireFox或IE进行调试时,我没有这个问题。

我重新安装了Chrome浏览器,解决了这个问题一天。没有下载任何插件的问题再次发生了第二天。

什么是使Chrome重定向localhost到https?

网络巡检显示: 请求URL:数据:text / html, chromewebdata 请求头 显示临时标题 User-Agent:Mozilla/5.0 (Windows NT 6.3;WOW64) AppleWebKit/537.36 (KHTML,像Gecko) Chrome/36.0.1985.143 Safari/537.36

这些选项卡中没有预览和响应数据。


当前回答

Chrome 63强制。dev域通过预加载的HSTS自动转换为HTTPS。 快速修复:只需将.dev域更改为.localhost。

其他回答

为像我这样的懒人(在Chrome 67中工作)提供了一个懒惰和快速的解决方案。

只需在隐身模式下启动另一个Chrome窗口,使用“隐身窗口”选项(CTRL + SHIFT + N)。不需要删除缓存,不需要深入Chrome设置等。

不幸的是,这里列出的解决方案都不能帮助我解决这个问题。我通过使用http://127.0.0.1 (ip地址)而不是http://localhost修复了这个问题。一个用chrome浏览器进行角开发的小技巧。

The issue could be replicated in VS 2019 also. This is caused due to "Enable Javascript debugging from Visual Studio IDE". The VS attaches to Chrome and it is a possibility that due to security or reasons known to Google and Microsoft, it sometimes fails to attach and you have this issue. I am able to run http and https with localhost from ASP net core 3.1 app. So while debugging in VS, go to the run with arrow -> IIS express, just below "Web Browser(Chrome)" select "Script Debugging (Disabled)".

参见文章:https://devblogs.microsoft.com/aspnet/client-side-debugging-of-asp-net-projects-in-google-chrome/

https://learn.microsoft.com/en-us/visualstudio/debugger/debugging-web-applications?view=vs-2019

总是退回到微软文档,以获得比谷歌更清楚的问题。

这可能是由缓存的https重定向引起的,可以通过手动清除缓存来修复,如Adiyat Mubarak的回答。

但如果你访问localhost,你可能是一个开发人员,在这种情况下,你会发现一个缓存清理chrome扩展,如“经典缓存杀手”(见例如https://chrome.google.com/webstore/search/classic%20cache%20killer?hl=en)在各种情况下很有用,很可能已经安装了一个。

因此,快速解决方案是:安装一个缓存杀手(如果您还没有),打开它,然后重新加载页面。完成了!

尝试了上面提到的所有方法(浏览器首选项、hsts等),但都不适合我。

我通过在主机别名后面添加一个.localhost来解决这个问题。在我的例子中,这个文件在windows下:%windir%\system32\drivers\etc\hosts

是这样的:

127.0.0.1    myproject.localhost
127.0.0.1    dev.project.localhost