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.

Recommended Answers

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 …
Jump to Post

All 3 Replies

Member Avatar

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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.