Hi,

I am using the following method for removing HttpRuntime Cache:

HttpRuntime.Cache.Remove("Key");

But some times this code is not working.
Any kind of help will be appreciated.

Member Avatar for LastMitch

Unable to Remove HttpRuntime Cache

The issue is that your key was not specify.

You can used this:

Cache.Remove Method

This is an example

class YourCache{
    static void Main(){

    // add an item to the cache
     HttpRuntime.Cache["Key"] = "Keybar";
     Console.WriteLine(HttpRuntime.Cache["Key"]); 

    // remove the item from the cache
      HttpRuntime.Cache.Remove("Key");
      Console.WriteLine(HttpRuntime.Cache["Key"]); 
    }
}

I think LastMitch is right as your “Key” is not specified properly. Please specify your key within the code LastMitch has suggested.

Right! That will be Ok for your code it will run properly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.