473,770 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Examine items in the ASP.NET cache added using the OutputCache directive

Hi,

Does anyone know how to examine items in the ASP.NET cache that are added
using the OutputCache directive in framework 1.1

i.e.

<%@ OutputCache Duration="300" VaryByParam="No ne"
VaryByCustom="c mscontrol,cmsro le"%>

By examine I mean see their value, key and expiration time.

Cheers Ed.
Nov 19 '05 #1
1 2234
In the end I cludged it using a bit of hacked together reflection:

<%@ Page language="c#" AutoEventWireup ="false" %>
<%@ Import Namespace="Syst em.Collections" %>
<%@ Import Namespace="Syst em.Reflection" %>
<%@ Import Namespace="Syst em.Text" %>
<%@ Import Namespace="Syst em.Web.Caching" %>
<script runat=server>
override protected void OnInit(EventArg s e)
{
this.Load += new System.EventHan dler(this.Page_ Load);
base.OnInit(e);
}

private const string row = "<tr><td>{0 }</td><td>{1}</td><td>{2}</td></tr>";
private void Page_Load(objec t sender, System.EventArg s e)
{
StringBuilder outHtml = new StringBuilder(5 12);
outHtml.Append( "<table cellpadding=0 cellspacing=0 border=1>");
outHtml.Append( "<tr><td>Ke y</td><td>Value</td><td>Type</td></tr>");

// Grap the CacheInternal cache object from Cache using reflection
Type cacheType = Cache.GetType() ;
FieldInfo fieldCacheInter nal = cacheType.GetFi eld("_cacheInte rnal",
BindingFlags.De claredOnly | BindingFlags.No nPublic | BindingFlags.In stance);
Object cacheInternal = fieldCacheInter nal.GetValue(Ca che);
Hashtable _entries = (Hashtable)
cacheInternal.G etType().GetFie ld("_entries", BindingFlags.De claredOnly |
BindingFlags.No nPublic | BindingFlags.In stance).GetValu e(cacheInternal );

outHtml.Append( "<tr><td colspan=3>Count :" + _entries.Count + "</td>");
foreach (DictionaryEntr y entry in _entries)
{
Type typeCacheEntry = entry.Value.Get Type();
FieldInfo fldKey = typeCacheEntry. BaseType.GetFie ld("_key",
BindingFlags.De claredOnly | BindingFlags.No nPublic | BindingFlags.In stance);
FieldInfo fldValue = typeCacheEntry. GetField("_valu e",
BindingFlags.De claredOnly | BindingFlags.No nPublic | BindingFlags.In stance);

outHtml.Append( string.Format(r ow,
fldKey.GetValue (entry.Value).T oString(),
fldValue.GetVal ue(entry.Value) .ToString(),
fldValue.GetVal ue(entry.Value) .GetType().ToSt ring()));
}

literalOut.Text = outHtml.ToStrin g();
}
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Cache</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:Literal id="literalOut " runat="server"> </asp:Literal>
</form>
</body>
</HTML>

Ed.
"Edward Wilde" <ew****@hotmail .com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
Hi,

Does anyone know how to examine items in the ASP.NET cache that are added
using the OutputCache directive in framework 1.1

i.e.

<%@ OutputCache Duration="300" VaryByParam="No ne"
VaryByCustom="c mscontrol,cmsro le"%>

By examine I mean see their value, key and expiration time.

Cheers Ed.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1427
by: Jose Marciano | last post by:
Hello. Could someone tell me the way(s) of doing cache in old ASP pages? What i really wanted was to keep in cache for some time the HTML generated by an ASP page (something like the "@OutputCache" directive of .NET). Thank you in advance. Jose Marciano
2
16680
by: Jason Huang | last post by:
Hi, Kind of spending too much time on the no-cache issue and found out something like <% Response.CacheControl = "no-cache" %>. In my ASP.Net, a C# .aspx file, where do I put the <% Response.CacheControl = "no-cache" %>? Is this enough to fix the Caching bug? Thanks for help. Jason
6
2745
by: Tom Kiefer | last post by:
Question: If I have an ASP.NET User Control which defines/exposes a property that the page can use to specify a mode or data subset for the control to use, is there a way to tell the @OutputCache directive to vary its cache based on that property value? I.e., I have: <my:control runat="server" id="mcOne" Flag="One" /> <my:control runat="server" id="mcTwo" Flag="Two" />
4
1415
by: Proc | last post by:
I am hoping someone here can point me in the right direction with a problem my user's are experiencing. Here is what is happening: I have an ASP.NET application that several users will use at the same time in a classroom-like setting. They access the application concurrently and occasionally experience an issue where one user starts accessing the application (they click on a link which sends their name and login information to the...
11
3730
by: Steve Franks | last post by:
I see several reference to using the ASP.NET 2.0 Cache object in C# where the documentation just shows snippets like this: if (Cache == null) ... do something However when I use this code in a C# class that is called from an ASP.NET page, the compiler gives this error: 'Cache' is a tpe and cannot be used as an expression Furthermore when I type in Cache and press the "." for intellisense, the
2
1196
by: jack | last post by:
Now here i have a doubt the explorer maintains the cache for 300 seconds when the code is in html code like the one which is below :- <%@ OutputCache Duration="300" VaryByParam="none" %> But the same code when typed in the cs file of the page does not gives the same result. Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
1
1228
by: stupy1 | last post by:
I have a number of relatively static pages with a multivew control on each of them. What I'd like to do is cache these pages with either the outputcache directive or cache API. I've tried the outputcache with VaryByControl="MultiViewName" or with VaryByParam="none". When I do this only the first view I select resides in memory. Is there some way to cache the multiview control? thanks much, Justin
0
2091
by: Pete Griffiths | last post by:
Hi folks, I have an infuriating problem. I have a number of pages that I want to cache server-side only, using varybycustom. I have implemented a GetVaryByCustomString in my global.asax. I am setting the caching behaviour in the Page_Load as follows: Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache) Response.Cache.SetValidUntilExpires(True)
4
2739
by: RedHair | last post by:
Development: Windows 2003 Production :Windows 2003 ASP.NET 2.0 + C# I want to disable the cache feature of all pages in dev but enable it in production environments. What's the solution? If uses cacheProfiles in web.config then I need to deploy different web.config files from dev to production sites.
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.