Brian Mains Brian Mains - 2 months ago 8
ASP.NET (C#) Question

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

I have an ASP.NET MVC project, with an ASP.NET web api defined as an area in this project. So the structure is the following:

MVC Web
Controllers
Views
Areas
API (web API)
Controllers


The app works as expected. However, I am having an issue with debugging. I can put a debugger in the MVC controller, and it works as expected. I cannot put a breakpoint in the web API controller, as I get "the breakpoint will not currently be hit. No symbols have been loaded for this document." I've been in the throes of it for some time, so it's probably a simple fix but I cannot figure it out. Any ideas why I'm getting this problem with web API controllers, when I can debug an MVC controller?

Answer

Until you find a permanent solution you can use the method System.Diagnostics.Debugger.Break() to force a break to occur on that line - just like a breakpoint:

public ActionResult IndexCheckInOut(string providerKey, DateTime? date = null)
{
    System.Diagnostics.Debugger.Break();   
    return View("Index");
}

Here are some links to articles that might help you find a more permanent solution:

The breakpoint will not currently be hit

Stepping into ASP.NET MVC source code with Visual Studio debugger