22

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?

Julian
  • 33,915
  • 22
  • 119
  • 174
  • Does this help [Developing locally with ASP.NET Core under HTTPS, SSL, and Self-Signed Certs](https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx)? Try running `dotnet dev-certs https --trust`. – Dave Anderson Sep 30 '19 at 22:33
  • Check the certificate mappings, https://docs.jexusmanager.com/tutorials/https-binding.html and make sure they point to the right certificate. – Lex Li Oct 01 '19 at 03: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 Oct 01 '19 at 21:52
  • I've repaired Visual Studio 2019, lost all my extensions installs, and still the same issue is there :'( – Julian Oct 01 '19 at 21:53

11 Answers11

30

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
Radu Bartan
  • 483
  • 6
  • 12
8

Repair of IIS Express fixed my problem:

enter image description here

Julian
  • 33,915
  • 22
  • 119
  • 174
  • 1
    Thanks for having saved my life! – Canada Wan Aug 27 '20 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 Sep 17 '20 at 15:24
  • I'm getting error in repairing IIS..its like looking for a file.. – aj go Mar 02 '21 at 04: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 Aug 04 '23 at 18:26
7

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
Vahid Mehrabi
  • 598
  • 10
  • 19
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

Julian
  • 33,915
  • 22
  • 119
  • 174
Rajon Tanducar
  • 308
  • 4
  • 8
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.

Ankush Jain
  • 5,654
  • 4
  • 32
  • 57
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
Arvind Maurya
  • 910
  • 12
  • 25
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.

Julian
  • 33,915
  • 22
  • 119
  • 174
BrettB
  • 104
  • 4
1

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

Amir Aghajani
  • 367
  • 2
  • 5
0

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

SendETHToThisAddress
  • 2,756
  • 7
  • 29
  • 54
Bashar Abu Shamaa
  • 1,998
  • 2
  • 21
  • 36
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.

Julian
  • 33,915
  • 22
  • 119
  • 174
Sayed Mahmoud
  • 66
  • 2
  • 10
-2

Clear your browser history and cookie

dennis
  • 11
  • 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](https://en.m.wikipedia.org/wiki/OSI_model) – Julian Dec 20 '20 at 16:14