我想开发一个简单的CMS。
我想添加向 CMS 添加模块的功能。
这样的 CMS 需要什么样的架构?
一个解决方案,然后是网站的 mvc 项目和管理员的另一个?还是一个有管理员区域的项目?
在 mvc 中,我的每个模块都有一个控制器、模型和视图。如果我将所有内容放在一个项目中,那么我将混合所有模块,每个模块将位于 3 个文件夹中(控制器、模型和视图)。
我需要如何安排它们,这样我的代码才会干净整洁?
我想开发一个简单的CMS。
我想添加向 CMS 添加模块的功能。
这样的 CMS 需要什么样的架构?
一个解决方案,然后是网站的 mvc 项目和管理员的另一个?还是一个有管理员区域的项目?
在 mvc 中,我的每个模块都有一个控制器、模型和视图。如果我将所有内容放在一个项目中,那么我将混合所有模块,每个模块将位于 3 个文件夹中(控制器、模型和视图)。
我需要如何安排它们,这样我的代码才会干净整洁?
Since you are only separating by type of user, you can surely (and easily) include in one project. all of your Admin controllers should have [Authorize(Roles="Admin")] on them to limit them only for the admin. Mixing them is fine, other applications mix user roles in an application on a regular basis, just limit the difference by security (and dont use url restrictions in your web.config - use the [Authorize] attribute on your controllers instead!! If you expect the differences in both applications to be huge then you can separate into another project, but I'm imagining you can get very good reuse by including them in the same project.
How to architect this is a very very broad question. For a basic project some include everything all in one project. I prefer to break out all my models and data access code into a separate project and try to code to interfaces as much as possible for unit testing purposes. I think that is all a bit beyond the scope of the posting here though. To start - work with the mentioned attribute and I think you will develop. Start unit testing early and I think that will help steer you into the right direction. Also read up on dependency injectiom , unit, ninject, etc for ways to dynamically bind to your implementation classes as this makes your unit test go quite a bit smoother as well.