Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear the server cache in asp.net?

How do I clear the server cache in asp.net? I have found out that there are two kinds of the cache. There is the browser cache and the server cache. I have done some searching but I have yet to find a clear, step-by-step guide for clearing the server cache using asp.net (or not).

(update) I just learned that the code-behind for this is in VB - Visual Basic (dot net).

like image 834
xarzu Avatar asked May 13 '13 22:05

xarzu


People also ask

How do I manually clear .NET cache?

When the service has stopped, go to the following locations and delete any folders under the folder of root (. NET cache) leaving the root folder alone: C:\Windows\Microsoft.NET\Framework\v2. 0.50727\Temporary ASP.NET Files\root.

Where is asp net cache?

The cached data is stored in server memory. Class Caching : Web pages or web services are compiled into a page class in the assembly, when run for the first time. Then the assembly is cached in the server. Next time when a request is made for the page or service, the cached assembly is referred to.


1 Answers

You could loop through all the cache items and delete them one by one:

foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){     HttpContext.Current.Cache.Remove(string(entry.Key)); } 

Syntax Correction for ASP.NET 4.5 C#

foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){     HttpContext.Current.Cache.Remove((string)entry.Key); } 
like image 103
Kenneth Avatar answered Oct 09 '22 03:10

Kenneth