To which process should I attach Visual Studio Debugger to debug a Kestrel application?

ⅰ亾dé卋堺 提交于 2019-12-04 05:50:45

Unfortunately, there is no way to tell right now using the tools provided by Visual Studio or .NET Core. Notice, though, that the community has already requested for this feature here, so you can voice your opinion there.

Currently, the best option is to follow the steps to find out the id of the process given the application's port:

  1. Run netstat -abon | findStr "127.0.0.1:{PORTNUMBER}"
  2. Find the Id of the process returned above, and, for faster lookup, the name will be dotnet.exe

If you feel adventurous, you may want to use something like this PowerShell, which will return directly the port number:

 $string = netstat -abon | findStr "127.0.0.1:{PORTNUMBER}"; $results = $string.split(' '); $results[$results.length - 1]
Ruben Bartelink

You can print the pid to the console and use that to select from Ctrl-Alt-P

Console.WriteLine($"Running at pid {System.Diagnostics.Process.GetCurrentProcess().Id}");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!