ASP.NET-MVC – ASP.NET MVC – Strong Type View Model, where is it?

I am trying to create a strongly typed view model, John Sheehan suggested here. Where should it go? I can defend myself for models, views and controllers.
It should be placed in the “Models” directory of the web application By definition, ViewModels are specific to one or more views and therefore belong to the web application, not the core.

You can define them in the controller that uses them, but this will not Extension. Same as defining classes in the view code. Even if one class per file means more files, it is easier to find the code and easier to maintain.

I often create one for each controller Subfolder, so I ended up with something like Web.Models.Foo.BarViewModel.

I am trying to create a strongly typed view model, as John Sheehan suggested here. Where should it go? I can defend myself for models, views and controllers.

It should be placed in the “Models” directory of the web application. By definition, ViewModels are specific to one or more Views, therefore belong to the web application, not the core.

You can define them in the controller that uses them, but this will not extend. The same as defining the class in the view code. Even though One class per file means more files, it is also easier to find the code and easier to maintain.

I often create a subfolder for each controller, so I end up with something like Web. Something like Models.Foo.BarViewModel.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2100 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.