如何在同一解决方案中从MVC项目调试Web API项目 [英] How To Debug Web API Project From MVC Project In Same Solution

查看:121
本文介绍了如何在同一解决方案中从MVC项目调试Web API项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2012中,我正在尝试使用对Web API项目的jQuery调用来创建MVC 4 Web应用程序. (其他开发人员将在我们当前的本机应用程序中使用该API,并且将来可能会添加到该API中.)因此,我有一个项目是Web API,另一个项目是MVC 4网站.我只能将其中之一设置为运行,并且它们使用localhost:xxxxx.

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.

如何调试对两者的更改?例如,假设我添加了一个新的API路径/api/customer/get,然后向该路径添加了一个新的jQuery ajax调用,并使用生成的JSON做一些事情.我已经在两个项目中都更改了代码,并且想要端到端地遵循它;如何同时启动两者?如何调试两者?

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?

请明确一点,MVC应用程序未在服务器端调用API,我主要是在使用MVC,以便能够轻松地使用中的捆绑,缩小和(希望)预编译的Handlebars模板.网; API调用来自jQuery.由于我对这些技术还比较陌生,因此欢迎提出其他建议.

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.

谢谢.

推荐答案

我遇到了同样的问题,并从这里找到了解决方案:

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

forums.asp.net

解决方法是执行以下操作:

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)

下一步选择多个启动项目.选择您的网站和Web服务,并在操作"列中确保它们都选择了开始".

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

现在,当您调试网站并将断点放置在Web服务中时,它应该会到达断点.

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

这篇关于如何在同一解决方案中从MVC项目调试Web API项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆