Should strongly typed partial views on one page in asp.net mvc-2 have one combined view model?

I have a question that asp.net mvc-2 strongly typed partial views and looked at models.

I'm just wondering if I can (or should) have two strongly typed partial views on the same page without implementing a completely new presentation model for this page.

For example, I have a page that displays profiles, but also has a built-in form to add a quick contact. Each of these objects already has its own representation model, i.e. I have a ProfileViewModel and ContactViewModel.

So, for my view, I need two strongly typed partial views, one of which uses IEnumerable List of ProfileViewModels, and the other using ContactViewModel. Is it possible or desirable to avoid creating a third view model, the “IndexViewModel” for this page, which contains a list of ProfileViewModels and ContactViewModel? Is this model implementing improper presentation practices or more accurate, as this leads to a decrease in viewing models?

Thank!

+3
source share
1 answer

, , , , - . , IEnumerable<ProfileViewModel> , , , . ContactViewModel ? , IEnumerable<ProfileViewModel>.

IEnumerable<ProfileViewModel>, ContactViewModel. , , , . , ViewData[].

, - . , , - . , , .

, view-models - . , . , , . , , , . " " , ( , .) , , .

+1

Source: https://habr.com/ru/post/1746943/


All Articles