Search code examples
c#asp.net-mvcmodel-view-controllerdirectory-structure

c# MVC - folder structure - where to put classes?


In asp/net MVC, the project is divided into Models, Views and Controllers. Fine so far.

Say I have a Class 'person', which the people controller populates with data, using the person model.

Where is it best to put my person.cs class? In the controllers or the models folder? What do you do?

Thanks

Frank


Solution

  • I'd create another class library project in the solution, define my classes and then reference my library in my ASP.Net MVC application.

    WebApp Solution
    |-MyMVCProject
      |-Models
      |-Controllers
      |-Views
    |-MyMVCProject.Domain (you'd put your models here)
      |-Person.cs
    |-MyMVCProject.Services (you'd put entity services here)