41

I am running a simple ASP.net web application. Chrome is showing the below error after running this.

localhost sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR

but my application is on http, not https.

enter image description here

but the URL is loading with https://localhost:54056/

config is also pointing to http only.

 <site name="tan-square" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Users\Myfolder\OneDrive\Downloads\tan-square" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:54056:localhost" />
            </bindings>
        </site>

I don't understand where the problem is. Why is it loading with https?

karel
  • 5,489
  • 46
  • 45
  • 50
James123
  • 11,184
  • 66
  • 189
  • 343
  • What if you switch to another web browser? Chrome has been insane on pushing its own restrictions (on certificates and so on), so really not a good browser for debugging. – Lex Li Mar 06 '20 at 16:45
  • Look here: https://stackoverflow.com/questions/43338665/this-site-can-t-provide-a-secure-connection – Arsen Khachaturyan Mar 03 '23 at 08:36

7 Answers7

96

First, check your site web binding detail by the following detail:

  1. Open visual studio, select your project.

  2. right-click on the project and select properties.

  3. under the Web tab and check your project url.

enter image description here

make sure there no such setting in your web.conifg file like below:

<system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Strict-Transport-Security" 

        value="max-age=16070400; includeSubDomains" />
      </customHeaders>
    </httpProtocol>
</system.webServer>

When the browser sees this, it will remember, for the given number of seconds, that the current domain should only be contacted over HTTPS. In the future, if the user types http:// or omits the scheme, HTTPS is the default.

Clear your browser cache.

Another thing you could try to find the cause is open chrome and type chrome://net-internals/#hsts in the address bar and search for localhost:

enter image description here

The query shows “localhost” as being in the list of domains in the HSTS set.

The solution is deleting the domain from the cache. type “localhost” into the Delete domain text field, and hit Delete. After doing that when you query for “localhost” again you will receive a “Not found”.

enter image description here

Serj Sagan
  • 28,927
  • 17
  • 154
  • 183
Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26
5

Just create new Virtual Directory:

1-right-click on the project and select properties.

2-under the Web tab change your project url by changing the localhost to http://localhost:48333/ .

3- click Create Virtual Directory.

4- make sure you don't have this in web.config

<system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains"/>
      </customHeaders>
    </httpProtocol>
</system.webServer>
Jamal Qudah
  • 81
  • 1
  • 3
  • This is by far the most simple solution. Just remember to be sure that your Web.confg transform is proper as show in the example above by Jalapa_Panchal. – PhillipPDX Aug 11 '22 at 10:23
1

If you are running .net core, just run Visual Studio as admin, or go to bin\Debug\netcoreapp3.1 directory, and issue. Wierdly, .net core. .net core surprisingly dont give any error.

%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-3.1.exe --port 5059

change port number to whatever.

VineetYadav
  • 783
  • 1
  • 5
  • 10
  • Interestingly running VS as admin solved the problem for me, then subsequently running VS without elevated privileges the browser no longer reported the error. – Tom John Oct 12 '22 at 10:41
1

Go to launch settings change the launch URL to https instead of http, it will ask you to add self generated ssl , click Yes and it Run the project. Hope this will help you

Arun Raut
  • 19
  • 2
0

In my case "clearing SSL State" has solved my issue.

  • Open the Start menu.
  • Search for and open Internet Options.
  • In the dialog box that appears, select the Content tab.
  • Click Clear SSL State.
Muzaffer Galata
  • 580
  • 1
  • 9
  • 22
0

VS will do this automatically if you add an ssl port to the iisbindings section of launchsettings.json. There is no UI to do it but you can edit the file directly.

{
    "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
        "applicationUrl": "https://localhost/WebApplication",
        "sslPort": 443
    },
    "iisExpress": {
        "applicationUrl": "https://localhost:62686",
        "sslPort": 44391
    }
},
Mohammad
  • 921
  • 7
  • 15
-4

Change default browser to Chrome and the issue is solved.

  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 11 '22 at 08:31