求救啦
同时使用自定义OutputCacheProvider和CacheDependency时报错
System.Configuration.Provider.ProviderException: 使用像“xxx”这样的自定义输出缓存提供程序时,仅支持以下到期策略和缓存功能: 文件依赖关系、绝对到期、静态验证回调和静态替换回调
运行环境为 vs2010 mvc3 windows7
“静态验证回调和静态替换回调”是什么意思?????
堆栈跟踪:
[ProviderException: 使用像“xxx”这样的自定义输出缓存提供程序时,仅支持以下到期策略和缓存功能: 文件依赖关系、绝对到期、静态验证回调和静态替换回调。]
System.Web.Caching.OutputCache.InsertResponse(String cachedVaryKey, CachedVary cachedVary,
String rawResponseKey, CachedRawResponse rawResponse, CacheDependency dependencies, DateTime absExp, TimeSpan slidingExp) +2915947
System.Web.Caching.OutputCacheModule.OnLeave(Object source, EventArgs eventArgs) +107
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
public class MyCacheDependency : CacheDependency
{
public MyCacheDependency(string fileName)
: base(fileName,DateTime.Now)
{
}
public void NotifyChanged()
{
NotifyDependencyChanged(this, new EventArgs());
}
}
public class MyOutputCacheProvider : OutputCacheProvider
{
private Dictionary<string, object> caches = new Dictionary<string, object>();
public override object Add(string key, object entry, DateTime utcExpiry)
{
caches[key] = entry;
return entry;
}
public override object Get(string key)
{
if (caches.ContainsKey(key))
{
return caches[key];
}
return null;
}
public override void Remove(string key)
{
caches.Remove(key);
}
public override void Set(string key, object entry, DateTime utcExpiry)
{
caches[key] = entry;
}
}