Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 779
Brian Mains Avatar asked Jan 01 '13 01:01

Brian Mains


2 Answers

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

like image 51
Sampath Avatar answered Sep 30 '22 09:09

Sampath


For me it worked out to just stop IIS and restart Visual Studio. Definitely worth a try before further investigation.

like image 38
FrKunze Avatar answered Sep 30 '22 10:09

FrKunze