ASP.NET MVC project structure
My team is migrating over from ASP.NET WebForms to ASP.NET MVC. Our Visual Studio solution would exist of the following projects:
Now, with ASP.NET MVC it seems that everything goes, by default, into a single solution, with Model, View, and Controller subfolders.
However, we are considering separating the original layers like we did before.
As mentioned we are relatively new to ASP.NET MVC, so we would like to hear if anyone used a similar approach, or have better suggestions?
Walt Lynton, Feb 07, 2010
Hi, you should take a look at my video series that does just that, except exposing a public api. http://www.mvccentral.net and look for the Golf Tracker Video series. I hope that helps. King Wilder email@example.com
Mar 29, 2010
I found the M in the MVC slightly confusing at first. The layers I have chosen are similar to yours, as I wanted the Service Layer on top of the Data and Business Layer.
My initial ideas (prompted by some examples from the books on MVC) made me place the model classes (domain/business) into the Models sub-folder of the ASP.NET MVC project. Of course, it is possible (as I have seen it was encouraged for the sake of simplicity) to ignore the Models folder and make a dependency on the layers on the lower levels, e.g., Service.
At the moment my Models folder is used for keeping objects that are closely related to the presentation layer, such as forms, UI flow-specific objects, and data transfer objects crafted for browser display purposes, etc.).
I did it because in my past projects when I was trying to decouple the service layer from the presentation layer, I found that services 'knew too much' about the flow, hence the need for something in between. I know that some people might frown upon yet another layer between the UI and the business logic layer (or services layer, in the matter of fact), but that is what I have found useful so far.
So in my case the Models folder serves a purpose of separating the UI-specific stuff (such as forms, their temporary data, states, flow logic, etc.) from the service layer. I would not keep Data Layer or reusable services in Models, in my case that would go outside ASP.NET MVC project to something like Integration layer that serves a purpose of mediating between clients (UI is just one of them) and the Service and Business Layers.
The increased number of layers makes the system more flexible and easier to evolve and maintain in the long term.
Dariusz Kaminski, Feb 16, 2010