MVC 缓存技术

以下为MVC5缓存Index页面实例:

控制器代码:

[OutputCache(Duration = 20)]//给index添加10秒缓存  OutputCache:给index添加的缓存标签
public ActionResult Index()
{
ViewBag.Time2 = DateTime.Now.ToLongTimeString();

IQueryable<M_MappingTable> m = _mappingTableService.download();
return View(m);
}

视图代码:

 

@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<text>选择上传文件:</text><input name="file" type="file" id="file" />
<br />
<br />
<input type="submit" name="Upload" value="Upload" />
}

 

<div class="bar2"><h2>@ViewBag.Time2</h2></div>

 

posted on 2016-01-08 12:31  Andy_陈  阅读(136)  评论(0编辑  收藏  举报

导航