摘要: 1、Example - UsingViewDataControllerpublicActionResultIndex(){List<string> colors =newList<string>();colors.Add("red");colors.Add("green");colors.Add("blue");ViewData["listColors"] = colors;ViewData["dateNow"] =DateTime.Now;ViewData[" 阅读全文
posted @ 2011-11-14 21:50 EasyPass 阅读(545) 评论(0) 推荐(0) 编辑
摘要: 1、ViewDataViewData的生命周期和View相同, 只对当前View有效。2、TempDataTempData保存在Session中, Controller每次执行请求的时候会从Session中获取TempData并删除Session。获取完TempData数据后虽然保存在内部的字典对象中。但是TempData集合的每个条目访问一次后就从字典表中删除。也就是说TempData的数据至多只能经过一次Controller传递。并且每个元素至多只能访问一次。3、ViewBagViewBag 是 MVC3 新增语法,ViewBag 不再是字典的键值对结构,而是 dynamic 动态类型,它 阅读全文
posted @ 2011-11-14 21:47 EasyPass 阅读(1179) 评论(0) 推荐(0) 编辑