1、创建asp.net mvc测试项目StrongType(需要framework 4.5+)
2、添加Controller=Home,View=Index
3、在Models文件夹下添加测试实体类 Student
4、【单一实体】在HomeController的Index Action中初始化一个Student类,并返回
5、【单一实体】在Index页面顶部添加【@model Student】,即可在此页面中使用强类型的智能提示
6、【实体列表】在HomeController的Index Action中初始化一个Student列表,并返回列表。修改Index页面顶部添加【@model @model List<Student>】
7、从Controller传递到V坡纠课柩iew的model实际上是通过ViewData.Model传递的。所以,下面两种写法是一样的效果: 1)return View(student) 2)ViewData.Model = student; return View();