Julian
Julian

Reputation: 36820

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

I've installed Visual Studio 2019 and uninstalled Visual Studio 2017.

Now if I start an ASP.NET (Core) site with https, it always say on Chrome:

This site can’t provide a secure connection

or on Edge

Can’t connect securely to this page

Screenshots:

Chrome:

enter image description here

Edge:

enter image description here

The URLs are correct. This also the same http://localhost:56784/ (it redirects to https)

enter image description here

Tried

What I've tried:

Issue

I think the issue is introduced by:

The underlining issue looks like a wrong/old/not supported TLS version?

Question

What can I do to diagnose/fix the problem?

Upvotes: 25

Views: 47538

Answers (11)

BrettB
BrettB

Reputation: 114

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/

Save (but don't run the Project).

Edit .vs/[ProjectName]/config/applicationhost.config and change the bindings for the web project to this:

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

Reopen Visual Studio and when I started the website it worked.

Upvotes: 2

Sayed Mahmoud
Sayed Mahmoud

Reputation: 138

If you 'are using services.AddHttpsRedirection like

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.

Upvotes: 0

Amir Aghajani
Amir Aghajani

Reputation: 387

In my case use SSL check box was gone in debug section of project properties. everything was fixed by checking again

Upvotes: 2

Mustafa Yıldırım
Mustafa Yıldırım

Reputation: 91

I solved this problem as follows;

  1. run the web project in debug mode on Visual studio 2019.
  2. if it's on chrome you should do this ; Empty cache and hard reload

Upvotes: 2

Ankush Jain
Ankush Jain

Reputation: 7069

Just follow below steps:

  1. Close Visual Studio
  2. Delete .vs folder
  3. Restart Visual Studio
  4. Build and Run the Application

As per my understanding, .vs folder keeps the old settings inside the applicationhost.config file. So better to delete all cached settings and start with fresh.

Upvotes: 4

Bashar Abu Shamaa
Bashar Abu Shamaa

Reputation: 2029

Right click on the project, select Properties, 'Debug', check the checkbox "Enable SSL", that's it, worked with me by doing this

Upvotes: 0

Vahid Mehrabi
Vahid Mehrabi

Reputation: 674

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

Upvotes: 11

Rajon Tanducar
Rajon Tanducar

Reputation: 378

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. Now delete the domain enter image description here

Delete the domain by typing localhost enter image description here

Upvotes: 6

Radu Bartan
Radu Bartan

Reputation: 563

Just as it did not work for @Nosnetrom - repairing IIS 10.0 Express did not work for me either. As @Julian mentioned my problem was caused by uninstalling VS 2017 as well.

This is what did not work for me:

  • uninstalling / re-installing VS 2019
  • installing VS 2017
  • uninstalling / re-installing / repairing 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 enter image description here
  • then I updated the applicationhost.config file according to this advice. The location of said file on my Windows 10 machine is: 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: enter image description here
  • then in Visual Studio I created a new virtual directory enter image description here
  • that seemed to have done the trick for me - when I ran the application it worked enter image description here

Upvotes: 38

dennis
dennis

Reputation: 11

Clear your browser history and cookie

Upvotes: -2

Julian
Julian

Reputation: 36820

Repair of IIS Express fixed my problem:

enter image description here

Upvotes: 9

Related Questions