0
在我的MVC項目中,除了顯示當前時間(這是動態的)之外,還有一些靜態內容的頁面。我想要緩存這個頁面,但是由於時間原因我無法緩存。動態更新MVC中緩存頁面的一部分
我嘗試使用DonutCatching,但它不工作。 以下是我嘗試使用DonutCatching的代碼。
主控制器:-Search.cs
[OutputCache(Duration=3600)]
public ActionResult Index()
{
return View("Main.cshtml");
}
public ActionResult Part()
{
return View("Date.cshtml",DateTime.Now);
}
Main.cshtml
@using DevTrends.MvcDonutCaching;
<div></div>
<div></div>
@Html.Action("Part","Search",true)
<div></div>
<div></div>
Date.cshtml
@model DateTime
<h2>@Model</h2>
我想緩存日Main.cshtml但部分更新每次請求Main.cshtml。任何解決方案或我在上面做錯了什麼?
你爲什麼不乾脆使用JavaScript是什麼? – Robert
Javascript工作正常,但如果我想顯示廣告而不是日期,那我該怎麼辦? – yajiv