28
votes

I am using Microsoft Visual Studio 2019 Community preview, version 16.4.0 Preview 1.0. I just update to Windows 10 Pro Version 1903 OS build 18362.418 . With ASP.NET Core 3 web-app project (Blazor Server), When I press F5, I catch error

I can go to https://localhost:44333/ manually, but it is inconvenient. When I stop debug, I also turn off it manually at taskbar.

With another web-app project, the problem is not happen.

When I choose or not choose option Enable native code debugging, not success.

How to fix it?

14
Do you just want to attach to the process? Then possible duplicate of stackoverflow.com/a/49297776/1260204 (".. you will have to attach "dotnet.exe" process in Visual Studio")Igor

14 Answers

27
votes

Enable/disable SSL

This is the easy fix. For me, toggling the "Enable SSL" setting in the project Debug tab inside Visual Studio (just change it to the opposite of what is currently set and run the project) has fixed the issue.

As I understand it, there are two reason this might work. First it causes Visual Studio to update the Applicationhost Config (more about that later). Secondly, sometimes the SSL address is bound. Therefore disabling SSL disables the problem.

Applicationhost Config

Open your $(solutionDir)\.vs\config\applicationhost.config file and ensure your site looks like this:

<site name="[YOUR PROJECT NAME]" id="3">
  <application path="/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="//PATH/TO/YOUR PROJECT" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:[YOUR_PORT]:localhost" />
    <binding protocol="https" bindingInformation="*:[YOUR_SSL_PORT]:localhost" />
  </bindings>
</site>

Make sure iplisten is configured to 0.0.0.0

If the IP listen list is not configured, this issue may occur (caution, I have no idea why).

Check netsh to ensure there is an entry for 0.0.0.0

PS C:\Windows\system32> netsh http show iplisten

IP addresses present in the IP listen list:
-------------------------------------------

::     
0.0.0.0

PS C:\Windows\system32>

Add the correct netsh rule if it does not exists. You'll need an admin cmd.exe or admin PowerShell for this.

PS C:\Windows\system32> netsh http add iplisten ipaddress=0.0.0.0

Ensure nothing is binding to the address you are using

This seems to be an issue with Blazor for me. If an address is binded to the address Blazor is trying to use, this can cause issues. Use netsh again to check what is in use.

netsh http show urlacl

An entry that looks like this

Reserved URL            : http://*:50902/
    User: \Everyone
    Listen: Yes
    Delegate: No
    SDDL: D:(A;;GX;;;WD)

Can be deleted with this command

netsh http del urlacl url=http://*:50902/
24
votes

I had the very same issue what OP described, I mean I got the error message, but checking the IIS Express icon, it was shown everything is OK, so manually going to the url was working.

Tried literally everything what is described above including

  • Stop the site within IIS Express
  • Stop IIS Express
  • Exit VS restart VS
  • Check everything in the .vs folder
  • Delete the .vs folder
  • as a POC created a brand new ASP.NET Core project, that worked properly

Nothing helped.

I know it is ridiculous as "solution", but after spending a half hour with this I finally restarted my machine and everything is working since then... Worth a try

15
votes

Thought I would throw in what worked for me even though I'm late to the party. The solutions above didn't work for me.

  1. Went to the properties of the project -> Debug Tab
  2. Changed the port number in the AppURL to x + 1, i.e. for my instance http://localhost:44348 => http://localhost:44349
  3. Closed the solution
  4. Deleted the applicationhost config
  5. Reopened solution.
  6. Changed the port number back to the original

Voila

4
votes

I have had this problem occasionally in the past. I can often resolve the problem by:

  1. Click on show hidden icon area of task bar. You'll see an IIS Express icon.
  2. Select the icon and you should see your website listed. Drill down in that menu click "Stop site".

On other occasions I have had corporate security software interfere with Visual Studio/IIS Express operations. Usually you can get around the issue by running Visual Studio as Administrator. I've attempt explain to the security guys what an awful idea that is but usually they do not understand.

Finally, if you are running a Asp.Net Core application you can just give up on IIS Express. If you look next to the play button, there is a drop list that says "IIS Express". If you open the list you'll see your application's name there. Select that one. You'll be running using kestrel instead of IIS Express.

4
votes

I had the same issue, I was able to solve it by changing the Port number.

  1. Right click on the project and select properties
  2. Go to the Debug section
  3. Under Web Server Settings change App URL port [just increase by one]
4
votes

Nothing worked for me (including deleting .vs, deleting obj and bin, cleaning the projects, restarting VS Studio, running netstat -ao | findstr <port number> to find out who is using my port and so on). Nothing.

Nothing except this:

  1. Open PowerShell as an administrator
  2. Run Get-Process -Id (Get-NetTCPConnection -LocalPort MY-PORT-NUMBER).OwningProcess (change port number to your port number)
  3. Finally, in my case, this showed that this process: service host: windows push notifications system service is using my port. Note the ID of this process and..
  4. Go to Task Manager (more details) > Processes > find the process by that ID and kill the child process (because this parent process itself can't be killed without the system becoming unusable)

That's it. It was windows push notifications system service in my case. Once I found it and killed it - everything is working without having to restart the whole computer or changing the port number.

3
votes

I resolved this by closing Visual Studio (2019) and started it back up, running as Administrator.

1
votes

For me I had another application using the same port, I changed the port in project debug settings to something else.

1
votes

Changing the application url (by right clicking on the solution -> properties -> debug -> app url) from http://localhost:59017 to http://localhost:5901 (last number 7 deleted) worked for me. enter image description here

1
votes

Removing .vs folder will solve this issue.

  1. Go to application location
  2. Remove .vs folder(hidden folder)
  3. Start project again!
0
votes

Another option, and the one I prefer because one should not have to waste time fighting with IISExpress, is to run your project launch profile and not the IISExpress one.

Blazor is a .NET Core app so you can debug it with Kestrel.

0
votes

I had the same issue. I was connected to my organization VPN. I simply disconnected the VPN, restarted IIS and tried again. It works fine now,

0
votes

I had exactly the same problem with IIS Express that seemingly appeared out of nowhere. My solution was to simply open IIS Manager and restart IIS (in the right-side panel under Actions -> Manage Server). As a result, project start-up resumed working right away.

0
votes

I was facing same issue, i tried all the way, i did not get proper solution. Finally i was resolved using below steps. In VS goto Tools=>Options=>Projects and solutions=>Web projects=> click checkbox -Use the 64 bit version of IIS express for website and projects.

With this i came out of my issue.