Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3241310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:11:02+00:00 2026-05-17T18:11:02+00:00

I have ASP.Net application with a simple cache helper. Under VS web server it

  • 0

I have ASP.Net application with a simple cache helper.
Under VS web server it works fine.
Under IIS 6.0 cache doesn’t work- object, was saved previos, doesn’t returns after a minute (with no exception).
What could be wrong?

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);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:11:02+00:00Added an answer on May 17, 2026 at 6:11 pm

    Maybe nothing is technically wrong. A cache does not mean that any object will be returned the moment after it is persisted.

    If your site is caching a lot of items and the cache is not big enough it may constantly be looking for objects to remove from the cache. In this situations, sometimes the object that has only just been cached can be a good candidate to be removed. If you had room for 100 objects and the cache was full with items that had been accessed at least once, then it may never cache your new object that “has never been accessed”. This does actually happen on the odd occasion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net application running under IIS 6. A simple page has two
I work on a web application in ASP.NET and HTML5. I have a simple
A simple question. I have an ASP.NET web application which contains several assemblies and
We have a very simple ASP.NET web application comprising mostly static content and a
I have an Asp.net application hosted on a shared server. I have few cache
I have a simple level ASP.NET web application based on Castle ActiveRecord. How can
I have a very large ASP.NET application in C#. The issue is simple yet
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have an ASP.Net 4.0 web application which very frequently loads data from the
I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.