使用ASP.NET的WebAPI有一个3层架构 [英] Using ASP.NET WebApi with a 3 Tier Architecture

查看:77
本文介绍了使用ASP.NET的WebAPI有一个3层架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图获得与使用ASP交手。 NET的WebAPI最近,我看过了一堆教程,并阅读了不少材料,但没有找到我需要的信息。这可能是一个非常基本的问题,但我的想法是我的主机与IIS的WebAPI,并瞄准了一个3层建筑,有点像,presentation层,业务记录和数据访问。

I have been trying to get to grips with the use of ASP. NET WebApi recently, I’ve watched a bunch of tutorials and read quite a bit material, but not finding the information I need. This maybe a very basic question, but my idea is to host my webapi with IIS and was aiming for a 3 tier Architecture, something like, Presentation Tier , Business Log and Data Access.

现在我创建一个MVC 4项目为我的presentation层。但我不理解非常好是我然后创建一个网页API模板另一个MVC 4项目为我的业务逻辑,并去掉所有的控制器,视图等?

Now I create an MVC 4 project for my presentation tier. But what I am not understanding very well is do I then create another MVC 4 project with a web api template for my business logic and strip out all the controllers, views etc?

希望我做的感觉。
谢谢阅读。

Hope I’m making sense. Thanks for reading.

推荐答案

你是否应该举办的WebAPI比你的MVC项目一个单独的ASP.NET应用程序是值得商榷的。这两种方法都是正确的。例如,如果你不想给的WebAPI暴露你可以承载它的一些内部网络,这是只有你的MVC应用程序访问的市民。如果你想将它暴露给公众,那么你可以与你的MVC应用程序一起主持它。所以,这将真正取决于您是否要暴露一个HTTP API向公众或没有。

Whether you should host the WebAPI in a separate ASP.NET application than your MVC project is debatable. Both approaches are correct. For example if you don't want to expose the WebAPI to the public you could host it in some internal network that is accessible only by your MVC application. If you want to expose it to the public then you could host it alongside with your MVC application. So it would really depend whether you want to expose an HTTP API to the public or not.

这篇关于使用ASP.NET的WebAPI有一个3层架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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