什么是相同或不同的项目具有的WebAPI的利弊 [英] What are the pros and cons of having a WebAPI in the same or different project

查看:95
本文介绍了什么是相同或不同的项目具有的WebAPI的利弊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC应用程序,并将该溶液包括三个项目的描述如下:

I have an MVC application and the solution consist of three project as described below:

Store.Domain:具有域实体和逻辑(库实体框架创建)

Store.Domain : Holds the domain entities and logic (repositories created with the Entity Framework).

Store.WebUI:举行了控制器和视图;作为应用程序的用户界面。

Store.WebUI : Holds the controllers and views; acts as the UI for the application.

Store.UnitTests:保存单元测试的另外两个项目

Store.UnitTests : Holds the unit tests for the other two projects.

我会为了对一些Android应用程序的创建Web服务使用的WebAPI 2在我的应用程序。现在我不知道下面的问题:

I will use WebAPI 2 in my application in order to create web services for some of the Android applications. Now I am not sure about the issues below:

1)通过在考虑到安全性和维护的担忧一致,我应该创造的WebAPI一个单独的项目,或在Store.WebUI项目中使用的WebAPI?正如我还将安装的WebAPI文档的NuGet,它会在项目中创建多个文件夹和文件,我想创建一个新的项目,也许更好。

1) By keeping in mind security and maintenance concerns, should I create a separate project for WebAPI or use WebAPI in the Store.WebUI project? As I will also install WebAPI documentation nuget and it will create several folders and files in the project, I think creating a new project maybe better.

2)假设以创建一个新项目专为的WebAPI,这将是对的WebAPI项目的项目类型和选择?这是真的以下选择的截图所示?

2) Assuming to create a new project dedicating for WebAPI, what would be the project type and choices for the WebAPI project? Is it true the following selections as indicated on the screenshot?

项目类型:ASP.NET Web应用程序

项目模板:只需选择Web API

Project Type: ASP.NET Web Application
Project Template: Just select Web API

先谢谢了。

推荐答案

的WebAPI是微软面向应用就像WCF的替代服务。但是WCF使用SOAP协议的WebAPI使用HTTP协议进行通信。

WebApi is an alternative Service oriented application from Microsoft just like WCF. But WCF uses SOAP protocol and WebAPI uses HTTP protocol for communication.

所以,如果你正在使用的WebAPI,为您的MVC应用程序提供服务,你会单独承载WEB API服务,并使用由MVC应用程序的服务,

So if you are using WEBAPI to provide service for your MVC application you would host that WEB API service seperately and consume its service by MVC application,

如果你想他们(MVC和的WebAPI)在同一个项目中使用,按照这个规则从<一个href=\"http://odeto$c$c.com/blogs/scott/archive/2013/07/01/on-the-coexistence-of-asp-net-mvc-and-webapi.aspx\"相对=nofollow>这篇文章。

If you want them (MVC and WebAPI) to use in the same project, follow this rules from this article.

希望有所帮助。

这篇关于什么是相同或不同的项目具有的WebAPI的利弊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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