Where should a ViewModel sit in the directory structure of an ASP.NET MVC application
I am about to create a Vi开发者_运维技巧ewModel to pass some data to a View. So if the application structure is convention based. Where are the ViewModel definitions to be kept. I could create a new directory called ViewModels, but what is the RIGHT way.
I don't think there's a widely accepted convention for this.
I have 'ViewModels' folder too.
I keep my view models in the Models folder because my data models reside in a separate assembly.
We've reluctantly settled on a models folder as well even though our views and controllers are in separate assemblies. We painted ourselves into the corner since we also use some of our WCF client-side DTOs directly in the view but those WCF client-side DTOs are generated in our controllers assembly. I blogged about our dilemma in some greater detail.
I keep all VM in a separate assembly (dll), so you can run tests easily against them - even outside ASP.NET scope...
精彩评论