在控制器把数据传递给界面(The controller transmits the data to the interface)

ViewBag             ViewData                TempData                  model

viewbag 一半存储一些不重要的数据 ViewBag.Content = “这是Controller里的数据”

 ViewData   

存储之后读取一次数据 读取了之后数据将被清空 TempData[“hello”] = “world”;

@*强类型视图*@@model WebApplication2.Models.Class1 @*model里的数据类型一定要于view方法参数里的model类型一致*@

 model

public ActionResult Login(string name,string pwd){Request.QueryString[“name”] Request.Form[“name”] if (name == “admin” && pwd == “123”)

 return Content(“ok”);elsereturn Content(“no”);

视图,SD去掉使用同名视图 母版页,_layout1去掉使用默认的模板页 数据 return View(“ShowData2”,masterName: __Layout1, new Class1()

———————————————————————————————–

————————

ViewBag               ViewData                 TempData                   model

Half of the viewbag stores some unimportant data. Viewbag.content = “this is the data in the controller”

 ViewData   

Read the data once after storage. After reading, the data will be cleared tempdata [“hello”] = “world”;

@*The data type in the strongly typed view * @ @ model webapplication2.models.class1 @ * model must be consistent with the model type in the view method parameter*@

 model

public ActionResult Login(string name,string pwd){Request.QueryString[“name”] Request.Form[“name”] if (name == “admin” && pwd == “123”)

 return Content(“ok”);elsereturn Content(“no”);

View, use the view master page with the same name_ Layout1 removes the default template page data return view (“showdata2”, mastername: _layout1, new class1()

———————————————————————————————–