开发者

The best way to organize the files in a large ASP.NET MVC2 project?

开发者 https://www.devze.com 2023-02-07 06:29 出处:网络
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

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 Contr开发者_开发知识库ollers 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.


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

To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as areas. Areas provide a way to separate a large MVC Web application into smaller functional groupings. An area is effectively an MVC structure inside an application. An application could contain several MVC structures (areas).

0

精彩评论

暂无评论...
验证码 换一张
取 消