Visual Studio 2019:"This site can’t provide a secure connection" 在本地主机上
Visual Studio 2019: "This site can’t provide a secure connection" on localhost
我安装了 Visual Studio 2019 并卸载了 Visual Studio 2017。
现在,如果我使用 https 启动一个 ASP.NET(核心)站点,它总是在 Chrome 上显示:
This site can’t provide a secure connection
或边缘
Can’t connect securely to this page
截图:
Chrome:
边缘:
网址正确。这也是相同的 http://localhost:56784/(它重定向到 https)
尝试过
我尝试过的:
- 已更新 Visual Studio 2019
- 创建一个新的 ASP.NET 核心 2 网站
- 使用 ASP.NET 站点(非核心)进行测试
- 使用 MMC 删除 IIS 证书
- Checking/changing Visual Studio 2019 中的 IIS 设置(带有上下文菜单的项目属性和带有 F4 的项目属性)
- 正在 Whosebug 上搜索 & Google ;)
- 修复 Visual Studio 2019
问题
我认为这个问题是由:
引起的
- 安装 Visual Studio 2019 and/or,
- 正在卸载 Visual Studio 2017 and/or,
- 正在更新 Windows 10(当前版本:10.0.18362 Build 18362)
下划线问题看起来像 wrong/old/not 受支持的 TLS 版本?
问题
我该如何解决 diagnose/fix 这个问题?
修复 IIS Express 解决了我的问题:
正如它对 @Nosnetrom
不起作用一样 - 修复 IIS 10.0 Express 对我也不起作用。正如 @Julian
提到的,我的问题也是由卸载 VS 2017 引起的。
这对我来说不起作用:
- 正在卸载/re-installing VS 2019
- 正在安装 VS 2017
- 卸载/re-installing/修复 IIS 10.0 Express
这是对我有用的:
- 阅读 this 建议后 - 我意识到我使用的是端口 51542 而不是 运行ge 44300 到 44399 中的端口
- 然后我根据this建议更新了applicationhost.config文件。上述文件在我的 Windows 10 机器上的位置是:
C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\applicationhost.config
。我必须以管理员身份在记事本 运行 中打开该文件,否则我无法保存这些更改:
- 然后在 Visual Studio 我创建了一个新的 虚拟目录
- 这似乎对我有用 - 当我 运行 应用程序工作时
清除您的浏览器历史记录和 cookie
我解决了这个问题如下;
- 运行 Visual studio 2019 年处于调试模式的 Web 项目。
- 如果它在 chrome 你应该这样做;
右键单击该项目,select 属性,'Debug',选中“启用 SSL”复选框,就是这样,通过这样做与我一起工作
None 以上解决方案对我有用,以下步骤对我有用。
转到 chrome 或边缘浏览器并键入 chrome://net-internals/#hsts
在查询域中搜索 localhost,您将找到包含 localhost 的域列表。现在删除域
通过键入 localhost 删除域
以上方法均无效者:
打开命令提示符,然后 运行:
dotnet dev-certs https --clean
然后:
dotnet dev-certs https --trust
只需按照以下步骤操作:
- 关闭Visual Studio
- 删除
.vs
个文件夹
- 重启Visual Studio
- 构建并运行 应用程序
据我了解,.vs
文件夹将旧设置保存在 applicationhost.config
文件中。所以最好删除所有缓存设置并从新开始。
None 这对我有用。什么起作用了(而且不像其他答案那么激烈)...
进入 web 项目并将 Start URL 和 Project URL 设置为:https://localhost:44365/
保存(但不要 运行 项目)。
编辑 .vs/[ProjectName]/config/applicationhost.config 并将 Web 项目的绑定更改为:
<binding protocol="https" bindingInformation="*:44365:localhost" />
<binding protocol="http" bindingInformation="*:53269:localhost" />
重新打开 Visual Studio 并且当我启动该网站时它运行正常。
如果你正在使用services.AddHttpsRedirection喜欢
services.AddHttpsRedirection(options =>
{
options.RedirectStatusCode = (int)HttpStatusCode.TemporaryRedirect;
options.HttpsPort = Configuration.GetValue<int?>("https_port", null);
});
确保 HttpsPort 为空或 appsettings.json 或 [=23= 中的有效端口] 文件.
在我的例子中,项目属性的调试部分中的使用 SSL 复选框消失了。通过再次检查一切都已修复
我安装了 Visual Studio 2019 并卸载了 Visual Studio 2017。
现在,如果我使用 https 启动一个 ASP.NET(核心)站点,它总是在 Chrome 上显示:
This site can’t provide a secure connection
或边缘
Can’t connect securely to this page
截图:
Chrome:
边缘:
网址正确。这也是相同的 http://localhost:56784/(它重定向到 https)
尝试过
我尝试过的:
- 已更新 Visual Studio 2019
- 创建一个新的 ASP.NET 核心 2 网站
- 使用 ASP.NET 站点(非核心)进行测试
- 使用 MMC 删除 IIS 证书
- Checking/changing Visual Studio 2019 中的 IIS 设置(带有上下文菜单的项目属性和带有 F4 的项目属性)
- 正在 Whosebug 上搜索 & Google ;)
- 修复 Visual Studio 2019
问题
我认为这个问题是由:
引起的- 安装 Visual Studio 2019 and/or,
- 正在卸载 Visual Studio 2017 and/or,
- 正在更新 Windows 10(当前版本:10.0.18362 Build 18362)
下划线问题看起来像 wrong/old/not 受支持的 TLS 版本?
问题
我该如何解决 diagnose/fix 这个问题?
修复 IIS Express 解决了我的问题:
正如它对 @Nosnetrom
不起作用一样 - 修复 IIS 10.0 Express 对我也不起作用。正如 @Julian
提到的,我的问题也是由卸载 VS 2017 引起的。
这对我来说不起作用:
- 正在卸载/re-installing VS 2019
- 正在安装 VS 2017
- 卸载/re-installing/修复 IIS 10.0 Express
这是对我有用的:
- 阅读 this 建议后 - 我意识到我使用的是端口 51542 而不是 运行ge 44300 到 44399 中的端口
- 然后我根据this建议更新了applicationhost.config文件。上述文件在我的 Windows 10 机器上的位置是:
C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\applicationhost.config
。我必须以管理员身份在记事本 运行 中打开该文件,否则我无法保存这些更改: - 然后在 Visual Studio 我创建了一个新的 虚拟目录
- 这似乎对我有用 - 当我 运行 应用程序工作时
清除您的浏览器历史记录和 cookie
我解决了这个问题如下;
- 运行 Visual studio 2019 年处于调试模式的 Web 项目。
- 如果它在 chrome 你应该这样做;
右键单击该项目,select 属性,'Debug',选中“启用 SSL”复选框,就是这样,通过这样做与我一起工作
None 以上解决方案对我有用,以下步骤对我有用。
转到 chrome 或边缘浏览器并键入 chrome://net-internals/#hsts
在查询域中搜索 localhost,您将找到包含 localhost 的域列表。现在删除域
通过键入 localhost 删除域
以上方法均无效者:
打开命令提示符,然后 运行:
dotnet dev-certs https --clean
然后:
dotnet dev-certs https --trust
只需按照以下步骤操作:
- 关闭Visual Studio
- 删除
.vs
个文件夹 - 重启Visual Studio
- 构建并运行 应用程序
据我了解,.vs
文件夹将旧设置保存在 applicationhost.config
文件中。所以最好删除所有缓存设置并从新开始。
None 这对我有用。什么起作用了(而且不像其他答案那么激烈)...
进入 web 项目并将 Start URL 和 Project URL 设置为:https://localhost:44365/
保存(但不要 运行 项目)。
编辑 .vs/[ProjectName]/config/applicationhost.config 并将 Web 项目的绑定更改为:
<binding protocol="https" bindingInformation="*:44365:localhost" />
<binding protocol="http" bindingInformation="*:53269:localhost" />
重新打开 Visual Studio 并且当我启动该网站时它运行正常。
如果你正在使用services.AddHttpsRedirection喜欢
services.AddHttpsRedirection(options =>
{
options.RedirectStatusCode = (int)HttpStatusCode.TemporaryRedirect;
options.HttpsPort = Configuration.GetValue<int?>("https_port", null);
});
确保 HttpsPort 为空或 appsettings.json 或 [=23= 中的有效端口] 文件.
在我的例子中,项目属性的调试部分中的使用 SSL 复选框消失了。通过再次检查一切都已修复