简体   繁体   English

来自 Visual Studio 调试的本地主机的 ERR_SSL_PROTOCOL_ERROR

[英]ERR_SSL_PROTOCOL_ERROR for localhost from Visual Studio debug

I am running a simple ASP.net web application.我正在运行一个简单的 ASP.net Web 应用程序。 Chrome is showing the below error after running this. Chrome 在运行后显示以下错误。

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

but my application is on http, not https.但我的应用程序是在 http 上,而不是 https。

在此处输入图像描述

but the URL is loading with https://localhost:54056/但 URL 正在加载https://localhost:54056/

config is also pointing to http only.配置也只指向http。

 <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?为什么要用 https 加载?

First, check your site web binding detail by the following detail:首先,通过以下详细信息检查您的站点 Web 绑定详细信息:

1)Open visual studio, select your project. 1)打开visual studio,选择你的项目。

2)right-click on the project and select properties. 2)右键单击项目并选择属性。

3)under the Web tab and check your project url. 3) 在 Web 选项卡下并检查您的项目 url。

在此处输入图片说明

make sure there no such setting in your web.conifg file like below:确保您的 web.conifg 文件中没有这样的设置,如下所示:

<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.当浏览器看到这一点时,它会记住,在给定的秒数内,当前域只能通过 HTTPS 联系。 In the future, if the user types http:// or omits the scheme, HTTPS is the default.以后,如果用户键入 http:// 或省略方案,则默认使用 HTTPS。

Clear your browser cache.清除浏览器缓存。 another thing you could try to find the cause is open chrome.您可以尝试查找原因的另一件事是打开 chrome。 type chrome://net-internals/#hsts in url and querying for localhost:在 url 中输入 chrome://net-internals/#hsts 并查询本地主机:

在此处输入图片说明

The query shows “localhost” as being in the list of domains in the HSTS set.查询显示“localhost”在 HSTS 集中的域列表中。

The solution is deleting the domain from the cache.解决方案是从缓存中删除域。 type “localhost” into the Delete domain text field, and hit Delete.在删除域文本字段中输入“localhost”,然后点击删除。 After doing that when you query for “localhost” again you will receive a “Not found”.这样做之后,当您再次查询“localhost”时,您将收到“Not found”。

在此处输入图片说明

Just create new Virtual Directory:只需创建新的虚拟目录:

1-right-click on the project and select properties. 1-右键单击项目并选择属性。

2-under the Web tab change your project url by changing the localhost to http://localhost:48333/ . 2-在 Web 选项卡下,通过将 localhost 更改为 http://localhost:48333/ 来更改您的项目 url。

3- click Create Virtual Directory. 3- 单击创建虚拟目录。

4- make sure you don't have this in web.config 4- 确保你在web.config 中没有这个

<system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains"/>
      </customHeaders>
    </httpProtocol>
</system.webServer>

If you are running .net core , just run Visual Studio as admin, or go to bin\\Debug\\netcoreapp3.1 directory, and issue.如果您正在运行.net core ,只需以管理员身份运行 Visual Studio,或转到 bin\\Debug\\netcoreapp3.1 目录,然后发出。 Wierdly, .net core.奇怪的是,.net 核心。 .net core surprisingly dont give any error. .net 核心令人惊讶地不会给出任何错误。

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

change port number to whatever.将端口号更改为任何内容。

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.转到启动设置,将启动 URL 更改为 https 而不是 http,它会要求您添加自行生成的 ssl,单击“是”并运行项目。 Hope this will help you希望对你有帮助

In my case "clearing SSL State" has solved my issue.就我而言,“清除 SSL 状态”解决了我的问题。

  • Open the Start menu.打开“开始”菜单。
  • Search for and open Internet Options.搜索并打开 Internet 选项。
  • In the dialog box that appears, select the Content tab.在出现的对话框中,选择“内容”选项卡。
  • Click Clear SSL State.单击清除 SSL 状态。

Change default browser to Chrome and the issue is solved.将默认浏览器更改为 Chrome,问题就解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM