Asp.Net Core: Debug -Attach to process is not working

To debug a running iisexpress instance in .Net core, you will have to attach "dotnet.exe" process in Visual Studio.
*Update - 1: If dotnet.exe does not work for you, check "{projectName}.exe" as well. *Update -2: Attaching "iisexpress.exe" works with .net 5


In Visual Studio 2019 using "dotnet watch run" I could no longer attach to the "dotnet.exe" process, I would get the Symbols could not be loaded error, took me a while to figure out but instead I attached to [project name].exe which is in the list of running processes and I could successfully attach the debugger to a process with symbols loaded and debug.


In my case, using Asp.Net Core 2.2 with InProcess Hosting Model, the accepted answer doesn't work. But, I should choose from the menu Debug > Attach to process, then select the "Show processes from all users" checkbox (below the list of process) and select "iisexpress.exe". It works properly and hit the break points.