Search code examples
asp.net-mvcconventionsconvention-over-configur

ASP.NET MVC: convention for organizing ViewModels


As discussed throughout the various MVC questions and blogposts, we know that the ASP.NET MVC project layout is heavy on convention.

I blindly made a sub-directory in the Controllers folder.

This doesn't feel right.

alt text http://www.imagechicken.com/uploads/1252003002097179400.png

Question: What's the common accepted convention on which directory to store your ViewModels? What are your suggestions or what is the established convention?


Solution

  • I think the idea is that (View)Models should go in the Models directory (which is empty when you create a new ASP.NET MVC project).

    Personally, it makes more sense for me to arrange namespaces around features instead of mechanics, but while this is of no consequence with regards to Models, it would have some implications when it comes to Controllers and Views.