再MVC中设置缓存非常简单
在action顶部设置outputcache来进行页面缓存
[OutputCache(Duration = 120, Location = OutputCacheLocation.Client,VaryByParam="id")]
public ActionResult getlist(int? id) {
int pagesize = 5;
Models.userinfo ui = new Models.userinfo();
IList<Models.userinfo> list = ui.getuser(id ?? 1,pagesize);
for (int i = 0; i < list.Count; i++)
{
string sql = "update userinfo set userpass='123456' where id='" + list[i].Userid + "'";
sqlhelper.ExecuteCommand(sql);
}
PagedList<Models.userinfo> lists = new PagedList<Models.userinfo>(list, id ?? 1, pagesize, ui.getcount());
return View(lists);
}