- /Controllers/ViewModels?
- /Views/ViewModels?
- Other?
views:
58answers:
4I like to have them at the root of the site /ViewModels or along side your Model folder (inside of it).
It depends on how you want to structure your project and how widely the model is supposed to be used.
You can create a separate folder and put all the View Model classes, or even just define them inside the controller class it correlated to.
However, if you are looking at layered development/structure for later web service implementation, I would recommend you to put them in a separate class library. It would be more clean and reusable across projects.
/Models
Since the "M" in MVC implies the models used for the views, and you are using view models, it seems just inside the "Models" folder is a prime location for them.
Whenever I start working in a non-trivial MVC application, the domain models end up being in an separate project from the MVC project. This makes it an even more tempting location because the default-created "Models" folder has no use without view models (yet deleting it feels wrong for some reason).