应用程序设置一个单独的Web API项目和ASP.NET应用程序

应用程序设置一个单独的Web API项目和ASP.NET应用程序

问题描述:

我试图使用来自另一ASP.NET经典项目的Web API服务(实际上它是一个本地的JS和HTML的Web应用程序)。
我该如何配置这些这些两个分离的项目与对方交谈,在VS2012?

I am trying to consume a Web API service from another ASP.NET classic project (actually it is a native JS and Html Web application). How can I configure these these two separated projects to talk with each other, on VS2012?

最后的结果将是:

http://localhost:8080/api/products

将由路由到位于的WebAPI项目的ProductsController返回的产品(JSON)的列表,




will return a list of products (JSON) by routing to ProductsController located on the WebAPI project,
And

http://localhost:8080/index.html

将被路由到的的项目页面 - 原生HTML / JS项目

will be routed to this page on the Second project - The native HTML/JS project.

如何配置逻辑到物理目录在这两个项目?
谢谢!

How can I configure the logical to physical Directories in these two project? Thanks!

事实证明它的pretty简单。
所有我所要做的就是配置这些两个项目共享本地IIS的同一端口:
所以对于本地JS / HTML(我的第二个项目)我使用:


As it turned out it's pretty simple. All I had to do is configure these both projects to share the same port on the local IIS: So for the native JS/HTML (my second project) I use:

和第二个项目(WEB-API项目):

And the second project (WEB-API project):

这就是它!
现在JS可以使用Web-API!

That is it! Now the js can consume the Web-Api!