2

SOS! I'm totally new to Visual Studio and am trying to learn C#, so I'm really struggling to find the right tools and terms to resolve my issue.

I just installed VS yesterday and ran into this issue on my very first Blazor WebAssembly app. I'm using Visual Studio 2019 8.9.6, Mac OS, Google Chrome.

When I create a new Blazor WebAssembly application, I'm running into the following issue:

  1. Click run (Debug > Google Chrome is automatic setting)
  2. Alert popup says: "dotnet quite unexpectedly" (I click Ignore, clicking Report and Reopen didn't change results.)
  3. Chrome says "Your connection is not private" > Advanced > Proceed to localhost
  4. Chrome says "This site can’t be reached" -- error code ERR_CONNECTION_REFUSED
  5. I try to hard refresh, but same error comes up

I've done some research and have tried the following so far:

  • cleared browser cache and cookies
  • restarted Chrome / Visual Studio / laptop
  • uninstalled then reinstalled Visual Studio
  • deleted the hidden .vs folder, then re-opened VS and ran debugger
  • overrode domain security protocols for localhost (per this solution: chrome://net-internals/#hsts)

Oddly enough, it seems to run in Safari and Firefox okay, although I still have bypass "Your connection is not private". I'm already really comfortable with Chrome dev tools, so that's my preferred method of viewing the app.

Does anyone know what the issue is and how to correct it? I'm just so confused because I've followed all the standard setups and steps to creating this app. Thank you!

Screenshot - This site can't be reached

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
GBonds
  • 21
  • 1
  • 2

3 Answers3

1

I also encountered this issue but from vscode; here's what I did to fix it:

First find the port the application is running on when debugging. Open the file Properties/launchSettings.json and look for the profile that corresponds to the project name you used when you initiated the dotnet project template. Within that find the applicationUrl setting, which will have two Urls separated by a semicolon (one https and one http). Copy the https url to the clipboard.

Second, open the file .vscode/launch.json. Within the configurations section, add or edit url and for the property value, paste the value you copied from launchsettings.json. Now save launch.json and start debugging, the browser should now launch with the correct url. If you prefer to use a different browser you can set it from here as well.

Mike Strother
  • 321
  • 2
  • 10
0

I use IIS Express to compile the project and get the same error but if I change it does not occur. Also check the project file like this

  • _"I use IIS Express to compile the project"_ IIS Express is a web server not a compiler! – phuzi Feb 07 '23 at 13:54
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 14 '23 at 10:51
0

I found that clearing the browser cache and re-loading (usually CTRL-F5) solved the problem for me.

RonnieScotland
  • 132
  • 2
  • 5