62

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?

2
  • 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. Commented Mar 6, 2020 at 16:45
  • Look here: stackoverflow.com/questions/43338665/… Commented Mar 3, 2023 at 8:36

9 Answers 9

122

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 (in edge type edge://net-internals/#hsts) 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

Sign up to request clarification or add additional context in comments.

10 Comments

I did the chrome thing and it worked for me. Thanks!!
For me, clearing chrome cache solved this issue.
Perfect! Nothing else worked for me.
Removing localhost from HSTS prison did the trick for me! Nothing else was working!!! Thanks!!!
I am running an .net 6 web project In VS2022 and there is no section 'Web' in the project settings.
|
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>

1 Comment

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.
2

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.

Comments

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.

1 Comment

Interestingly running VS as admin solved the problem for me, then subsequently running VS without elevated privileges the browser no longer reported the error.
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

Comments

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
    }
},

Comments

0

Just use IIS, waste of time to solve Microsoft bugs.

Comments

0

I also was getting the same error message, but yet another root cause for me. In my case it was a null reference error due to a property I never set in the ViewBag. I had a condition like this in my .cshtml file:

@if (ViewBag.Property1)
{
    // do stuff
}

But the property was never set. You'd think this would throw a null reference error or just evaluate to false, but no.

ViewBag.Property1 = "some value";

After setting the ViewBag property in my controller the error went away.

Comments

-5

Change default browser to Chrome and the issue is solved.

1 Comment

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.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.