Вместо этого вы можете использовать RenderAction. Пример:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
return View();
}
[OutputCache(Duration = 6000, VaryByParam = "none")]
public ActionResult Cached()
{
// You could return whatever you want here, even a view
// but for the purpose of the demonstration I am simply
// returning a dynamic string value
return Content(DateTime.Now.ToLongTimeString(), "text/html");
}
}
и внутри представлений Index.cshtml
и About.cshtml
вы можете включить дочернее действие:
<div>
@{Html.RenderAction("Cached");}
</div>
и вы получите его кэшированную версию на обеих страницах.