Categories visual-studio-2012

How To Debug Web API Project From MVC Project In Same Solution

In VS 2012, I am attempting to create an MVC 4 web application with jQuery calls to a Web API project. (Other devs will be consuming the API with our current, native app, and probably adding to the API in the future.) So I have one project that is the Web API, and another project that is the MVC 4 website. I can only set one of them to run, and they use localhost:xxxxx.

How do I debug changes to both? For example, let’s say I add a new API path /api/customer/get and then a new jQuery ajax call to that path and do something with the resulting JSON. I’ve changed code in both projects and want to follow it end-to-end; how do I launch both? How do I debug both?

Just to be clear, the MVC app isn’t making server-side calls to the API, I’m using MVC mostly to be able to easily use bundling, minification, and (hopefully) pre-compiled Handlebars templates in .NET; the API calls are coming from jQuery. As I am still relatively new to these technologies, alternate suggestions are welcome.

Thank you in advance.

I had the same problem and have found a solution from here:

The fix is to do the following:

In your solution file, click properties go to the Startup project node (if it is not already selected)

Next select Multiple startup projects. Select your website and your webservice and in the Action column make sure both of them have “Start” selected.

Now when you debug your website and put a break point in your webservice, it should hit the break point.