
[英]MVCDonutCaching - how to remove Child action cache MVC Donut Caching
[英]MVCDonutCaching - Issues with child action when parent is not donut cached
我正在使用Nuget的awesom MVCDonutCaching包来缓存整个页面,同时保留某些未缓存的部分。 这个过程很简单,一切正常:
我缓存如下:
[DonutOutputCache(CacheProfile = "FiveMins")]
public ActionResult Index()
{
return View();
}
对于我的页面部分,我不想缓存我正在执行以下操作:
@Html.Action("HeaderLinks","Home", true)
这应该工作,实际上页面的大部分是缓存但我的标题链接 - 上下文敏感链接显示登录按钮,如果用户没有登录,他们的用户名,如果他们是,等等 - 没有缓存。 到目前为止一切正常。
我遇到的问题是headerlinks属于主/布局页面并且全面使用 - 无论Action是否设置了DonutOutputCache属性。 当我创建另一个动作时,让我们称它为“关于我们”,没有甜甜圈缓存属性我根本看不到我的标题链接
public ActionResult AboutUs()
{
return View();
}
查看源代码,我看到以下内容
<!--Donut#
<ActionSettings xmlns="http://schemas.datacontract.org/2004/07/DevTrends.MvcDonutCaching" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ActionName>HeaderLinks</ActionName>
<ControllerName>Home</ControllerName>
<RouteValues xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:KeyValueOfstringanyType>
<a:Key>Area</a:Key>
<a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema"/>
</a:KeyValueOfstringanyType>
</RouteValues>
</ActionSettings>
#-->
显然,在上面的例子中,由甜甜圈缓存库生成 - 链接部分被一些注释的XML替换。
简而言之,我的问题是:无论父操作是否使用圆环缓存,该库是否都可以重用相同的子操作?
任何帮助,将不胜感激。
目前,您需要将Html.Action与DonutOutputCache动作过滤器一起使用,以便渲染圆环孔。 如果您在没有DonutOutputCache的情况下使用Html.Action,您将看到上面概述的占位符注释。
这是一个疏忽,将在下一个版本中解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.