Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC - Solution Layout Suggestions

Tags:

I have been working with ASP.NET MVC for a couple of months now and I'm still not happy with the layout of my project's solution. I am trying to construct a mid-sized website CMS that is as portable and reusable as possible and there are some obvious problems in the design of it. I am looking for some advice regarding how I should structure my solution in consideration of separation of concerns. I've found a similar question here, but it doesn't really target some of the issues I am facing.

Right now this is how my solution is laid out:

+Project.Controllers - All Controller classes
P+roject.Controllers.Tests

+Project.Core - Utility classes including repetitive tasks and some configuration handlers (this project needs to be better fleshed out)
+Project.Core.Tests

+Project.Models - Model classes, Entity Framework context, and Repository classes
+Project.Models.Tests

+Project.Web - All Views and Content

One major thing I am currently missing is a place to stick my business logic and I feel I've been wrongly placing business logic in my repository classes as well as intermingling it in controller actions. Obviously, I'm very aware of this problem, I'm just not sure where I should placing my business logic in that solution layout. Does my solution structure need to change or can I safely keep that business logic in my Models project? Also, I really don't like that my EF Context is in the Models class, but I don't know of a way to isolate the data layer code from the Entity Classes needed in my model.

How is everyone else laying out their production ASP.NET MVC solutions?

like image 548
Nathan Taylor Avatar asked Aug 25 '09 15:08

Nathan Taylor


2 Answers

You might want to check out the layout the S#arp architecture project uses or the onion architecture as used in the Code Camp Server MVC reference application. Both projects have had allot of effort put into them by different people to get a good sepperation of concerns in the context of asp.net MVC and domain driven design.

like image 105
olle Avatar answered Oct 12 '22 05:10

olle


Personally I'm only learning MVC. My experience comes from ASP.NET WebForms but I would go with the layout proposed in the link you gave. The second answer, that is:

  • Models
  • Views
  • Controller
  • Services
  • Tests - one for each project.
like image 38
Finglas Avatar answered Oct 12 '22 05:10

Finglas