最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - IIS Express from Visual Studio 2022 is not able to run "This site can’t be reached (ERR_CONNECTION_RESET)&quot

programmeradmin2浏览0评论

I am trying to run a c# project from VS2022 in debug mode but I am getting the following error:

This site can’t be reached
The connection was reset.
Try:

Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_RESET

This is a framework 4.8 code running on https://localhost:20001. But this is also happening for core projects running on that same port from vs2022.

Any thoughts would be appreciated. Thanks in advance.

I am trying to run a c# project from VS2022 in debug mode but I am getting the following error:

This site can’t be reached
The connection was reset.
Try:

Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_RESET

This is a framework 4.8 code running on https://localhost:20001. But this is also happening for core projects running on that same port from vs2022.

Any thoughts would be appreciated. Thanks in advance.

Share Improve this question edited Mar 28 at 18:36 Lex Li 63.4k11 gold badges124 silver badges161 bronze badges asked Mar 28 at 18:01 Shahriar chandonShahriar chandon 595 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Reason:

It turns out that this issue was happening due to a missing SSL binding for that port as I am trying to use "https".

Confirm the missing of binding using netsh:

Running netsh command to show the current bindings did not show anything for the port 20001

netsh http show sslcert

Fix the binding:

To fix this we need to do the following:

Running the following command in a command prompt (with administrative privileges) creates a new Self signed Cert (if it does not exist already) and binds the localhost port 20001 to that cert.

> cd "C:\Program Files (x86)\IIS Express"
> IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:20001/ -UseSelfSigned

Explanation:

The IIS Express folder is generally located inside the program files (x86) folder even in windows 11. Inside the IIS Express folder, we have many utilities such as the IisExpressAdminCmd that accepts a param called "setupsslUrl", which further requires an url param and a cert param. In the above case, for the url, I have specified https://localhost:2001 and the cert is a self-signed cert.

In my case, I already had the IIS Express Cert in the "Trusted Root Certificates" section in the windows certificate manager (certmgr). So running the command created a new binding with that cert to port 20001.

Confirmation of the changes:

I confirmed it by running a netsh command in a command prompt (with administrative privileges).

netsh http show sslcert

the output showed:

Then I opened the certificate manager (certmgr.msc or msc.exe)

Running the site:

After that I ran the C# project from Visual Studio 2022 and it did not give me an error and the web site loaded correctly.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论