简体   繁体   English

Visual Studio 2019:本地主机上的“此站点无法提供安全连接”

[英]Visual Studio 2019: "This site can’t provide a secure connection" on localhost

I've installed Visual Studio 2019 and uninstalled Visual Studio 2017.我已经安装了 Visual Studio 2019 并卸载了 Visual Studio 2017。

Now if I start an ASP.NET (Core) site with https, it always say on Chrome:现在,如果我用 https 启动一个 ASP.NET(核心)网站,它总是在 Chrome 上显示:

This site can't provide a secure connection此站点无法提供安全连接

or on Edge或在边缘

Can't connect securely to this page无法安全连接到此页面

Screenshots:截图:

Chrome:铬合金:

在此处输入图像描述

Edge:边缘:

在此处输入图像描述

The URLs are correct.网址是正确的。 This also the same http://localhost:56784/ (it redirects to https)这也是相同的http://localhost:56784/ (它重定向到 https)

在此处输入图像描述

Tried尝试过

What I've tried:我试过的:

  • Updated Visual Studio 2019更新了 Visual Studio 2019
  • Create a new ASP.NET Core 2 website新建ASP.NET Core 2网站
  • Tested with a ASP.NET site (non core)使用 ASP.NET 站点(非核心)进行测试
  • Remove IIS certificates with MMC使用 MMC 删除 IIS 证书
  • Checking/changing the IIS settings in Visual Studio 2019 (project properties with context menu and project properties with F4)检查/更改 Visual Studio 2019 中的 IIS 设置(使用上下文菜单的项目属性和使用 F4 的项目属性)
  • Searching on Stackoverflow & Google;)在 Stackoverflow 和 Google 上搜索;)
  • Repair Visual Studio 2019修复 Visual Studio 2019

Issue问题

I think the issue is introduced by:我认为这个问题是由以下原因引起的:

  • Installing Visual Studio 2019 and/or,安装 Visual Studio 2019 和/或,
  • Uninstalling Visual Studio 2017 and/or,卸载 Visual Studio 2017 和/或,
  • Updating Windows 10 (current Version: 10.0.18362 Build 18362)更新 Windows 10(当前版本:10.0.18362 Build 18362)

The underlining issue looks like a wrong/old/not supported TLS version?下划线问题看起来像是错误的/旧的/不受支持的 TLS 版本?

Question问题

What can I do to diagnose/fix the problem?我能做些什么来诊断/解决问题?

Just as it did not work for @Nosnetrom - repairing IIS 10.0 Express did not work for me either.就像它对@Nosnetrom ——修复 IIS 10.0 Express 对我也不起作用。 As @Julian mentioned my problem was caused by uninstalling VS 2017 as well.正如@Julian提到的,我的问题也是由卸载 VS 2017 引起的。

This is what did not work for me:这对我不起作用

  • uninstalling / re-installing VS 2019卸载/重新安装VS 2019
  • installing VS 2017安装 VS 2017
  • uninstalling / re-installing / repairing IIS 10.0 Express卸载/重新安装/修复 IIS 10.0 Express

This is what worked for me:这对我有用

  • after reading this advice - I realized that I was using port 51542 instead of a port in the range of 44300 through 44399阅读建议后 - 我意识到我使用的是端口 51542 而不是 44300 到 44399 范围内的端口在此处输入图像描述
  • then I updated the applicationhost.config file according to this advice.然后我根据这个建议更新了applicationhost.config文件。 The location of said file on my Windows 10 machine is: C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\applicationhost.config .该文件在我的 Windows 10 机器上的位置是: C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\applicationhost.config I had to open that file in Notepad ran as an administrator otherwise I could not save these changes:我必须以管理员身份在记事本中打开该文件,否则我无法保存这些更改: 在此处输入图像描述
  • then in Visual Studio I created a new virtual directory然后在 Visual Studio 中我创建了一个新的虚拟目录在此处输入图像描述
  • that seemed to have done the trick for me - when I ran the application it worked这似乎对我有用 - 当我运行它的应用程序时在此处输入图像描述

Repair of IIS Express fixed my problem: IIS Express 的修复解决了我的问题:

在此处输入图像描述

None of this worked for me.这些都不适合我。 What did work (and it's not as drastic as the other answers)...什么起作用了(而且不像其他答案那么激烈)......

Go into web project and set Start URL and Project URL to this: https://localhost:44365/ Go 进入 web 项目并设置 Start URL 和 Project URL 为:https://localhost:44365/

Save (but don't run the Project).保存(但不要运行项目)。

Edit.vs/[ProjectName]/config/applicationhost.config and change the bindings for the web project to this: Edit.vs/[ProjectName]/config/applicationhost.config 并将 web 项目的绑定更改为:

<binding protocol="https" bindingInformation="*:44365:localhost" />
<binding protocol="http" bindingInformation="*:53269:localhost" />

Reopen Visual Studio and when I started the website it worked.重新打开 Visual Studio,当我启动该网站时它运行正常。

I solved this problem as follows;我解决了这个问题如下;

  1. run the web project in debug mode on Visual studio 2019.在 Visual Studio 2019 上以调试模式运行 web 项目。
  2. if it's on chrome you should do this;如果它在 chrome 上,你应该这样做; Empty cache and hard reload清空缓存和硬重载

For those who all the above methods didn't worked:对于以上所有方法都不起作用的人:

open a command prompt and then run:打开命令提示符,然后运行:

dotnet dev-certs https --clean

and then:接着:

dotnet dev-certs https --trust

In my case use SSL check box was gone in debug section of project properties.在我的例子中,使用 SSL 复选框在项目属性的调试部分消失了。 everything was fixed by checking again通过再次检查一切都已修复

Right click on the project, select Properties, 'Debug', check the checkbox "Enable SSL", that's it, worked with me by doing this右键单击项目,select 属性,“调试”,选中“启用 SSL”复选框,就是这样,通过这样做与我一起工作

None of the above solutions worked for me, Following steps worked for me.以上解决方案都不适合我,以下步骤对我有用。 Go to chrome or edge browser and type chrome://net-internals/#hsts search for localhost in query domain, you will find lists of domain including localhost. Go 到 chrome 或 edge 浏览器并输入chrome://net-internals/#hsts在查询域中搜索 localhost,您将找到包括 localhost 在内的域列表。 Now delete the domain现在删除域在此处输入图像描述

Delete the domain by typing localhost通过键入 localhost 删除域在此处输入图像描述

Just follow below steps:只需按照以下步骤操作:

  1. Close Visual Studio关闭 Visual Studio
  2. Delete .vs folder删除.vs文件夹
  3. Restart Visual Studio重新启动 Visual Studio
  4. Build and Run the Application构建并运行应用程序

As per my understanding, .vs folder keeps the old settings inside the applicationhost.config file.据我了解, .vs文件夹将旧设置保存在applicationhost.config文件中。 So better to delete all cached settings and start with fresh.所以最好删除所有缓存的设置并重新开始。

If you 'are using services.AddHttpsRedirection like如果您正在使用 services.AddHttpsRedirection 之类的

services.AddHttpsRedirection(options =>
{
    options.RedirectStatusCode = (int)HttpStatusCode.TemporaryRedirect;
    options.HttpsPort = Configuration.GetValue<int?>("https_port", null);
});

Make sure HttpsPort is null or a valid port in appsettings.json or appsettings.Development.json file.确保HttpsPortnull或 appsettings.json 或appsettings.Development.json文件中的有效端口。

Clear your browser history and cookie清除浏览器历史记录和 cookie

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM