ASP.NET MVC Strongly typed or dynamically typed views

Given the benefits of using strongly typed views to eliminate typed errors and using lambda expressions, why use a dynamically typed view? When I use them, I don’t feel as good as with strongly typed views. Am I missing something? Is there any special use for them? =)

Relations RaVen

+5
source share
2 answers

you are not because strongly typed representations give you ease of use and many advantages. If you have a complex model that can contain an instance of a list, another object besides FormViewModel can help you. therefore, there are very few scripts where you really need a dynamically typed view. for example, I have a product view, and I need to show categories on this subject, so I created a separate presentation model, and I used it for the Product and the list of categories.

   public class ProductViewModel
    {
        public Product Product { get; set; }
        public List<Category> Categories { get; set; }

    }

The main disadvantage of a dynamically typed view is that you need to write a large amount of code compared to strongly typed views.

+3
source

, , , - ( - ).

0

All Articles