Strongly typed view and dynamically typed view

I am starting to use ASP.NET MVC. And, as I see it, there are two approaches to transferring data for viewing:

  • Make a view that inherits ViewPage and passes the dynamic object to the view.
  • Make a strongly typed view that inherits ViewPage, and pass an instance of the custom view-model class to the view.

What are the pros and cons of each?

+5
source share
2 answers

, , , . , , , .

+4

JOSH DOOLAN, - . , :

Public Class Person

{
 String _name;
 String _age;
 Pet _pet;

 // gets & sets below..etc
 }

, , ( "" ), , Pet.

, , - , , "Pet". /, html-mvc- Html.ControlFor. , html, , :

Html.EditorFor(model => model.Pet, "Pet")  

, "pet" "Pet", , , .

-.

+3

All Articles