在大型 ASP.NET MVC2 项目中组织文件的最佳方式是什么?
我在网上查找了组织 ASP.NET MVC2 项目的最佳方法。我只见过人们使用 MVC2 项目的默认模板的示例。但是,如果项目将包含大量文件,那么这是组织项目的最佳方式吗?
我们正在构建一个应用程序,该应用程序主要围绕 jQuery for UI 和使用 JSON 的 ajax 构建。因此,正如您可以想象的,我们将有许多自定义 .js 支持脚本。
在我们的解决方案中,我们已将所有支持库(第三方和自定义)放入各自的项目中。解决方案中的 MVC2 项目也使用默认的 MVC2 模板。
在 MVC2 项目中,“起始”结构仍然几乎没有变化。在 Controllers 目录下,我们有每个控制器 AccountController.cs 和 HomeController.cs(例如)。在 Views 目录下,我们有三个子目录,分别为 Account、Home 和 Shared。在脚本目录中,我们还将其分为三个目录:Account、Home 和 Shared。最后我们有 Models 目录,它也分为 Account、Home 和 Shared 子目录。
正如您所看到的,我们并没有偏离基本模板太多。但是,当我们开始向其中添加内容时,我们意识到当我们获得 20 或 30 个视图和 100 个支持 .js 文件时,这可能会变得多么麻烦。
任何建议都会很棒!
谢谢。
I've looked all over the web for the best way to organize an ASP.NET MVC2 project. I've only seen examples of people using the default template for MVC2 projects. But is this the best way to organize your project if it is going to contain a large number of files?
We're in the process of building an application that is heavily built around jQuery for UI and ajax using JSON. So, as you can imagine, we will have many custom .js support scripts.
In our solution, we have placed all our support libraries (3rd party and custom) into respective projects. The MVC2 project that is also in the solution is using the default MVC2 template.
In the MVC2 project, the "starting" structure is still pretty much unchanged. Under the Controllers directory, we have each controller AccountController.cs and HomeController.cs (for example). Under the Views directory, we have three subdirectories named Account, Home, and Shared. In the Scripts, directory we have also divided that up with three directories, Account, Home, and Shared. And finally we have the Models directory, that is also divided into Account, Home, and Shared subdirectories.
As you can see we haven't deviated from the basic template that much. But, as we start adding stuff to this, we're realizing how cumbersome this might become when we get upwards to 20 or 30 views and 100 support .js files.
Any suggestions would be great!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑使用区域来组织您的视图/控制器/模型/内容。
这是 Microsoft 的一篇好文章: 演练:组织一个使用区域的 ASP.NET MVC 应用程序
Look into using Areas to organize your Views/Controllers/Models/Content.
Here's a good article from Microsoft: Walkthrough: Organizing an ASP.NET MVC Application using Areas