24

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:

  • Updated Visual Studio 2019
  • Create a new ASP.NET Core 2 website
  • Tested with a ASP.NET site (non core)
  • Remove IIS certificates with MMC
  • Checking/changing the IIS settings in Visual Studio 2019 (project properties with context menu and project properties with F4)
  • Searching on Stackoverflow & Google ;)
  • Repair Visual Studio 2019

Issue

I think the issue is introduced by:

  • Installing Visual Studio 2019 and/or,
  • Uninstalling Visual Studio 2017 and/or,
  • Updating Windows 10 (current Version: 10.0.18362 Build 18362)

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

Question

What can I do to diagnose/fix the problem?

4
  • Does this help Developing locally with ASP.NET Core under HTTPS, SSL, and Self-Signed Certs? Try running dotnet dev-certs https --trust. Commented Sep 30, 2019 at 22:33
  • Check the certificate mappings, docs.jexusmanager.com/tutorials/https-binding.html and make sure they point to the right certificate.
    – Lex Li
    Commented Oct 1, 2019 at 3:17
  • Thanks for the replies! dotnet dev-certs https --trust didn't work unfortunately. Also I don't think this is a certificate issue. I can't see even the certificate in browser as the connection is reset before the certificate is send.
    – Julian
    Commented Oct 1, 2019 at 21:52
  • I've repaired Visual Studio 2019, lost all my extensions installs, and still the same issue is there :'(
    – Julian
    Commented Oct 1, 2019 at 21:53

11 Answers 11

37

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
4
  • 3
    Give this man a medal! This is the only thing that worked for me VS2019 Community on a new machine. Commented Dec 15, 2020 at 13:29
  • what if I'm using swagger? will this approach work? I'm having issue since swagger is using http protocol..
    – aj go
    Commented Mar 2, 2021 at 4:41
  • Thank you so much for this solution. This saved me a lot of headache. Commented May 5, 2021 at 0:21
  • This worked for me running an older ASP.NET app in VS2022. In a more modern .NET Core MVC app, I simply had to enable SSL. Commented Apr 15, 2022 at 17:06
11

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
0
9

Repair of IIS Express fixed my problem:

enter image description here

4
  • 1
    Thanks for having saved my life!
    – Canada Wan
    Commented Aug 27, 2020 at 18:11
  • I have both VS2017 and VS2019, and I have OP's same problem with VS20129. I can't repair IIS Express 10, because my installed version is more recent than the version I downloaded from MS. :-P Any suggestions?
    – Nosnetrom
    Commented Sep 17, 2020 at 15:24
  • I'm getting error in repairing IIS..its like looking for a file..
    – aj go
    Commented Mar 2, 2021 at 4:43
  • What does the image said? All of the images are being blocked at my employer's building due to security risk, like virus for example. So what does the image said? Thanks
    – fletchsod
    Commented Aug 4, 2023 at 18:26
6

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

1
  • But then you will use http instead of https after this step?
    – Julian
    Commented May 7, 2021 at 7:16
4

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.

0
2

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
2
  • What do you mean with "reload permanent deletion"?
    – Julian
    Commented Jan 1, 2021 at 14:10
  • I mean, Empty Cache and Hard Reload Commented Jan 1, 2021 at 14:16
2

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

2
  • is this the same answer as from Bashar Abu Shamaa / Mar 22 2021 at 14:52? Please update that one!
    – Julian
    Commented Feb 14, 2022 at 16:34
  • This worked for me. Not sure how it got unchecked, but thank you! Commented Apr 13, 2022 at 14:46
2

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.

0

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

0

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.

-2

Clear your browser history and cookie

1
  • This is just guessing. A Secure connection (TLS) is on the presentation layer (or lower), and http (cookie) a least a layer higher, on the application layer. See OSI model
    – Julian
    Commented Dec 20, 2020 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.