MVC 4:多项目解决方案设计 [英] MVC 4: multiple projects solution design

查看:117
本文介绍了MVC 4:多项目解决方案设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个新项目,我们希望将VS2012与MVC 4一起使用。



其他项目将加入此解决方案,因为这些项目类似且可以重用大多数Controller层逻辑,模型层逻辑和View层逻辑。有ProjectID来区分项目。



每个项目的URL应以项目名称开头:http //:.... / projectname1 / {controller} / {action} / {projectid}

我们希望在MVC中为上述场景设计尽可能高效/灵活的解决方案。



1.Views图层:我们正在考虑拥有一个视图对于每个页面。从项目到项目,大多数页面内容应该相同。我们认为任何项目差异都可以通过使用部分视图(基于ProjectID)来处理。



2.模型层:结构类似于视图。



3.控制器层:我们希望每个视图都有一个控制器,其中包含与该视图相关的所有操作。我们认为可以使用自定义过滤器和子操作(基于ProjectID)来处理任何项目差异。



使用MVC时听起来是否合理?



使用MVC还有其他模式/最佳实践吗?



谢谢

We have a new project and we would like to utilize VS2012 with MVC 4.

Other projects will "join" this solution because those projects are similar and could re-use most of Controller layer logic, Model layer logic and View layer logic. There is ProjectID to distinguish between projects.

URL for each project should start with project name: http//:…./projectname1/{controller}/{action}/{projectid}
We would like to design solution as efficient/flexible as possible for above scenario in MVC.

1.Views layer: We are thinking to have one View for each page. Most of the page content should be the same from project to project. We think any project differences can be handled by using partial views (based on ProjectID).

2. Model Layer: structured similar to Views.

3. Controller Layer: we are thinking to have one controller per View with all actions related to that View. We think any project differences can be handled by using custom filters and child actions (based on ProjectID).

Does it sound as a reasonable approach when using MVC?

Are there any other patterns/best practices for using MVC?

Thank you

推荐答案

除了样板控制器之类的样板代码外,它们将具有共同的所有方面,并将其移动到dll并在您的项目之间共享它们。你可以看到,除非我能看到,否则你要求层层复杂而没有真正的好处。
Take all the aspects they will have in common, except boilerplate code like controllers, and move it to dlls and share them between your projects. You're asking for layers of complexity for no real benefit, as far as I can see, otherwise.


这篇关于MVC 4:多项目解决方案设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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