У меня есть приложение ASP.Net с простым помощником кеша. Под веб-сервером VS он отлично работает. В кеше IIS 6.0 не работает - объект, был сохранен ранее, не возвращается через минуту (без исключения). Что может быть неправильным?Кэш ASP.Net не работает в IIS 6.0
public static class CacheHelper
{
public static string Share<T>(T @object, TimeSpan period)
{
var uniqueKey = Guid.NewGuid().ToString();
HttpContext.Current.Cache.Add(uniqueKey, @object, null, Cache.NoAbsoluteExpiration,
period, CacheItemPriority.BelowNormal, null);
return uniqueKey;
}
public static void ShareViaCookie<T>(string key, T @object, TimeSpan period)
{
var cachedObject = GetFromCookie<T>(key);
if (ReferenceEquals(cachedObject, null))
{
var uniqueKey = Share(@object, period);
HttpContext.Current.Response.Cookies.Set(new HttpCookie(key, uniqueKey)
{
Expires = DateTime.Now.AddYears(1)
});
}
else
{
HttpContext.Current.Cache[GetKeyFromCookie(key)] = @object;
}
}
public static T GetShared<T>(string key)
{
string uniqueKey = HttpContext.Current.Request.QueryString[key];
return !string.IsNullOrEmpty(uniqueKey) ? (T)HttpContext.Current.Cache.Get(uniqueKey) : GetFromCookie<T>(key);
}
private static T GetFromCookie<T>(string key)
{
string uniqueKey = GetKeyFromCookie(key);
return !string.IsNullOrEmpty(uniqueKey) ? (T)HttpContext.Current.Cache.Get(uniqueKey) : default(T);
}
private static string GetKeyFromCookie(string key)
{
return HttpContext.Current.Request.Cookies[key]
.IIf(it => it != null, it => it.Value, it => null);
}
}
Опубликовать фрагмент кода. Очень трудно диагностировать, не видя кода. – MonkeyWrench
http://stackoverflow.com/questions/1330347/asp-net-cache-object-issues-after-migration-from-iis-5-to-iis-6 –