MVC 3项目结构

编程入门 行业动态 更新时间:2024-10-28 12:27:13
本文介绍了MVC 3项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图找到我的布局MVC 3项目的最佳途径。当网上搜索我碰到一个建议,基本上可以说项目上点击右键并添加区。这是什么做的是在同一个项目创建具有相同的控制器/视图/模型结构的区域文件夹。这不是我想要的。我想有单独的项目的灵活性。我将只保留在主Web项目的意见。一切都在一个单独的项目别人。

I am trying to find the best way to layout my MVC 3 project. When searching online I came across a suggestion that basically said right click on project and add area. What this did was create an area folder with same controller/view/model structure in the same project. This is not what I want. I want the flexibility of having separate projects. I will keep only the views in the main web project. Everything else in a separate project.

为实现这一尝试,我创建了一个单独的项目对我的控制器。现在我坚持指着控制器动作视图。在所有在线的例子是右键点击并添加视图。这是一个类库项目,我没有这种灵活性。 我在哪里去了?

Towards that attempt I created a separate project for my controllers. Now I am stuck with pointing a controller action to a view. In all the online examples it was right click and add view. This being a class library project I don't have that flexibility. Where am I going wrong?

这是我发现所有的例子包括那些我已经在 Asp经历主要讲解如何创建学习应用,仅用于学习的目的很好。一个大型的商业应用程序不可能拥有所有的意见/模型/在一个项目控制器。或者是,它应该在MVC要走的路? 我不知道如果与鼠标点击所做的一切,也是一个不错的主意。在web表单世界上也有很多是使用鼠标的研究,对于初学者应用点击创建基本的CRUD应用程序,但在真正的商业项目中,我们从来没有使用这些方法。

All examples that I have found including the ones I have gone through on Asp basically explain how to create study applications, which is only good for learning purposes. A large commercial application can't possibly have all the views/models/controllers in one project. Or is that the way it is supposed to go in MVC? I am not sure if doing everything with mouse clicks is also a good idea. In the webforms world also there were a lot of study-for-beginners applications that used mouse clicks to create basic CRUD applications, but in real commercial projects, we never used those methods.

你有什么想法,在这个指导?

What are your thoughts, guidance on this?

感谢您的时间...

推荐答案

MVC是基于一个惯例;该公约是你把所有的/的看法意见,模型/模型和控制器中/控制器。您可以更改该公约,但它不会让你的生活更轻松。

MVC is based on a convention; the convention is you put all the views on /views, the models in /models and the controllers in /controllers. You can change the convention but it will not make your life easier.

从概念的角度来看这有一定道理。如果你把所有的域逻辑和数据访问在不同的项目中,你只剩下都是网络相关的东西,你的控制器,视图模型和视图。这就是你的MVC项目。

From a conceptual point of view this does make sense. If you keep all domain logic and data access in separate projects all you are left with is the web related stuff, your controllers, view models and views. That's your MVC project.

请注意,如果你想要的部分剥离到单独的项目你可能会发现portable地区的有用。

Note that if you want to split off parts into separate projects you may find portable areas useful.

更多推荐

MVC 3项目结构

本文发布于:2023-07-15 23:03:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1115278.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:结构   项目   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!