应用程序设置一个单独的Web API项目和ASP.NET应用程序 [英] Setting app a separate Web API project and ASP.NET app

查看:139
本文介绍了应用程序设置一个单独的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!

这篇关于应用程序设置一个单独的Web API项目和ASP.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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