C# 未激发GetVaryByCustomString方法
当我在GetVaryByCustomString方法中放置断点时,它不会被激发 要缓存的操作取决于用户选择的语言:C# 未激发GetVaryByCustomString方法,c#,asp.net-mvc,outputcache,varybyparam,C#,Asp.net Mvc,Outputcache,Varybyparam,当我在GetVaryByCustomString方法中放置断点时,它不会被激发 要缓存的操作取决于用户选择的语言: [OutputCache(CacheProfile = "24HoursCache", VaryByCustom = "lang")] public ActionResult MyAction() { ... } Web.config中的缓存配置文件: <configuration> ... <system.web>
[OutputCache(CacheProfile = "24HoursCache", VaryByCustom = "lang")]
public ActionResult MyAction()
{
...
}
Web.config中的缓存配置文件:
<configuration>
...
<system.web>
...
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<clear />
<add name="24HoursCache" duration="86400" location="Client" varyByParam="none" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
...
</configuration>
任何帮助都将不胜感激,谢谢 实际位置必须设置为“服务器”,而不是“客户端”
...
...
...
而且很管用,呸
public override string GetVaryByCustomString(HttpContext context, string value)
{
if (value.ToLower() == "lang")
{
return Thread.CurrentThread.CurrentUICulture.Name;
}
return base.GetVaryByCustomString(context, value);
}
<configuration>
...
<system.web>
...
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<clear />
<add name="24HoursCache" duration="86400" location="Server" varyByParam="none" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
...
</configuration>