Comma
Comma

Reputation: 1607

ASP.net mvc 2 solution folder structure

What is the best way to organize a MVC2 web project (as complex as stackoverflow)? should i have everything in one project? if not, how should i separate the projects and folders?

Upvotes: 6

Views: 2062

Answers (3)

Anders Nygaard
Anders Nygaard

Reputation: 5552

I would start with a new ASP.NET MVC Project and then add a couple of more projects to your solution. I usually end up with:

MyProject
MyProject.Data
MyProject.Test

I normally put the generated classes from Subsonic (or other ORM tool) along with their repository classes in my .data project and my tests in the .test project. Apart from that, I use the main project as normal. Views in the Views folder, Models in the Models folder and so on.

Upvotes: 0

Mark Redman
Mark Redman

Reputation: 24545

Have a look at MVC Areas in MVC 2: http://msdn.microsoft.com/en-us/library/ee671793(VS.100).aspx

This is one way to organise code in larger projects.

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1039538

There's no best way. There are good and bad ways. Having everything in the same project is definitely not a good way. Big projects should be separated in layers and each layer usually goes into a different assembly so that it can be reused in other projects. For example you could have Models, Data Access, Business Logic, Web.

Jeffrey Palermo has a series of posts about the onion architecture which is worth reading.

From performance standpoint it is considered a good practice to have less bigger assemblies than many smaller assemblies.

Upvotes: 4

Related Questions