Search
Thursday, September 09, 2010 ..:: Home ::.. Register  Login
 .NET Links Minimize

 Print   
 My Links Minimize

 Print   
 Recent Blog Entries Minimize
Apr 9

Written by: Wil Dobson
4/9/2008 1:52 PM

The .NET Framework (2.0 in this case) contains a class exposing operations into the server Cache.  It's namespace/path is System.Web.Caching.Cache, and clearing it is the easy part. 

// declare a placeholder for your Cache data.
private System.Web.Caching.Cache TheCache;
// assign your placeholder to the value of your current webserver cache.
TheCache = HttpContext.Current.Cache;


And in your button click event handler:
        protected void btnClearCache_Click(object sender, EventArgs e)
        {
            // clear the cache
            foreach (DictionaryEntry key in TheCache)
            {
                string theKey = key.Key.ToString();
                TheCache.Remove(theKey);
            }
        }

 

Pretty simple, right? How about we make this a usercontrol, and provide the use with a list of current items in the Cache, as well as an option to remove only those he/she wants to remove as well as a clear all button?

Here is the code for my UserControl page (ucCacheKiller.ascx)

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucCacheKiller.ascx.cs"
    Inherits="WilsToolbox.ucCacheKiller" %>

        <table>
            <tr>
                <td align="left" colspan="2">
                    <asp:Label ID="lblCacheHeader" runat="server" Font-Bold="True" Font-Names="Tahoma"
      &am

Copyright ©2008 Wil Dobson

Tags:

  
 PS: Minimize

 Print   
 Sponsors Minimize

Get your own Komets drinking Stein!

Get your KOMETS gear!
Proceeds go for player awards @ the end of each season.

  Quality Geek Gear from GeeksWithGuns.com

We use DiscountASP!! Click to join up!


 Print   
 Facebook Minimize

Wil Dobson's Facebook profile


 Print   
 Blogs Minimize

 Print   
 Manage Blog Minimize
You must be logged in and have permission to create or edit a blog.

 Print   
 Blog Archives Minimize

 Print   
Copyright 2008 by Wil Dobson   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2010 by DotNetNuke Corporation