虚拟路径提供禁用缓存? [英] Virtual Path Provider disable caching?
问题描述
我有一个虚拟路径提供。问题是它的缓存我的文件。每当我手动编辑引用VPP不会在新文件中拉ASPX文件之一,它继续进行,直到我重新启动该网站重用旧文件。
I have a virtual path provider. Problem is its caching my files. Whenever I manually edit one of the aspx files it references the VPP doesn't pull in the new file, it continues to reuse the old file until I restart the site.
我在我的VirtualPathProvider类甚至过度骑着GetCacheDependency():
I've even over-rode the GetCacheDependency() in my VirtualPathProvider class:
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
return null;
}
想法?
Ideas?
推荐答案
返回一个空实质上是告诉你没有任何依赖ASP.NET - ASP.NET,因此不会重新加载项
Returning a null is essentially telling ASP.NET that you do not have any dependency - hence ASP.NET will not reload the item.
您需要的是返回一个有效的依赖性如
What you need is to return a valid dependency e.g.
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
return new CacheDependency(getPhysicalFileName(virtualPath));
}
有一个更正确的做法是,以确保您只处理自己的缓存依赖(这是一个示意性的例子):
A more correct approach is to make sure that you only handle your own cache dependencies (this is a schematic example) :
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
if (isMyVirtualPath(virtualPath))
return new CacheDependency(getPhysicalFileName(virtualPath));
else
return new Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}
这篇关于虚拟路径提供禁用缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!