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)

尝试过

我尝试过的:

问题

我认为这个问题是由:

引起的

下划线问题看起来像 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

我解决了这个问题如下;

  1. 运行 Visual studio 2019 年处于调试模式的 Web 项目。
  2. 如果它在 chrome 你应该这样做;

右键单击该项目,select 属性,'Debug',选中“启用 SSL”复选框,就是这样,通过这样做与我一起工作

None 以上解决方案对我有用,以下步骤对我有用。 转到 chrome 或边缘浏览器并键入 chrome://net-internals/#hsts 在查询域中搜索 localhost,您将找到包含 localhost 的域列表。现在删除域

通过键入 localhost 删除域

以上方法均无效者:

打开命令提示符,然后 运行:

dotnet dev-certs https --clean

然后:

dotnet dev-certs https --trust

只需按照以下步骤操作:

  1. 关闭Visual Studio
  2. 删除 .vs 个文件夹
  3. 重启Visual Studio
  4. 构建并运行 应用程序

据我了解,.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 复选框消失了。通过再次检查一切都已修复