MVC (ASP.NET MVC) 带 3 层架构如何协同工作? [英] How MVC (ASP.NET MVC) band 3-tier architecture can work together?

查看:30
本文介绍了MVC (ASP.NET MVC) 带 3 层架构如何协同工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写设计文档,我的团队成员愿意从 ASP.NET WebForm 迁移到 ASP.NET MVC.这很好,但我很难理解 MVC 如何在 3 层(数据层、业务层和表示层)架构中工作.我们可以说模型、视图和控制器是表示层的一部分吗?模型是业务层的一部分吗?

I am writing a design document and people on my team are willing to do the move from ASP.NET WebForm to ASP.NET MVC. This is great, but I have a hard time to understand how MVC workswith in a 3-tier (Data Layer, Business Layer and Presentation Layer) architecture. Can we say that the Model, View and Controller are part of the Presentation Layer? Is the Model part of the Business Layer?

简而言之,MVC 和三层架构如何协同工作?感谢您的帮助!

In brief, how MVC and 3-tier architecture can work together? Thanks for the help!

推荐答案

我认为 ASP.Net MVC 位于表示层.它使用的模型"类实际上是视图模型,它描述了视图所需的数据结构.您的所有业务逻辑和数据访问都应与 MVC 模型和控制器分开.

I consider ASP.Net MVC to be in the presentation layer. The "Model" classes it uses are really View Models, which describe the data structures needed by your views. All of your business logic and data access should remain separate from your MVC models and controllers.

此外,MVC 的一般最佳实践"是使控制器代码尽可能简单,这通常意味着将一些应用程序服务引入您的业务层来处理繁重的工作.

Also, the general "Best Practice" for MVC is to keep the controller code as simple as possible, which usually means introducing some for of application service into your business layer that handles the heavy lifting.

这篇关于MVC (ASP.NET MVC) 带 3 层架构如何协同工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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