3

(VS 2017 (v15.6.6), Dot Net Core, Win 10 Enterprise, using iisexpress.)

I have a fairly conventional Dot Net Core project that combines MVC Views and Web API.

My problem is debugging in the Web API Controllers. Breakpoints set in these controllers are being ignored. Whereas breakpoints set in non-API controllers are being hit.

Breakpoints in other projects in the same Solution that are entirely Web API work correctly.

I'm using 'Debug' mode. I've 'cleaned', done 'Rebuild solution', rebooted VS2017, reset iisexpress and rebooted the PC. All to no avail. The breakpoints are not being hit in WebAPI controllers.

I'm stumped. Other SO answers don't apply (I know I'm using debug, I can see the pdb files in bin\Debug\netcoreapp2.0, a restart doesn't help). Anybody else seen this?

UPDATE if I use IIS rather than iisexpress (and no other changes) the breakpoints are being hit. Looks like a bug in iisexpress?

SAL
  • 1,218
  • 1
  • 14
  • 34
  • Have you checked if the Web API project uses "Optimize code" build setting? It needs to be 'off' for debugging. See [this question](https://stackoverflow.com/q/8467059/1220550) for where to find it. – Peter B Apr 20 '18 at 14:30
  • @Peter B - 'Optimize code' is off – SAL Apr 20 '18 at 14:36
  • Start debugging. Then Debug->Attach to process find iisexpress.exe and attach. Then hit your app via the browser. – Russell Horwood Apr 20 '18 at 14:37
  • @Nine Tails - still no luck. It just sails on past... – SAL Apr 20 '18 at 14:48
  • It kinda sounds like the application is executing, and the debugger is attached, but the two aren't looking in the same direction. – Russell Horwood Apr 20 '18 at 14:50

1 Answers1

0

One workaround is that you could use the method System.Diagnostics.Debugger.Break() to force a break like a breakpoint.

Reference:

Web API in MVC Project isn't hitting breakpoints ("symbols not loaded")

Cant hit breakpoint in web api controller

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20