Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I use cache in ASPX but set expire can not excute. Pls look after:

I inserted line:

<%@ OutputCache Location="Client" Duration="60" VaryByParam="CID" %>


In code behide, in page load event:
if (Cache["Test"] == null)
            {
                Cache["Test"] = 123;
            }
            else
                Label1.Text = Cache["Test"].ToString();


After 1 min i refresh browser but Label1.Text = "123";

Pls help me!
Posted

Have a look at this part: VaryByParam="CID"
Any idea what that means? Have a look at the details of Vary-by-param caching here: @ OutputCache[^]
Caching Versions of a Page, Based on Parameters[^]

You get back the value as 123 as caching is varied by 'CID' querystring value.

More reads:
Caching in .NET[^]
Overview of caching[^]
 
Share this answer
 
Comments
Hiren solanki 28-Dec-10 8:43am    
comments from OP : Thanks for answer,
But i set
Collapse
VaryByParam="None"
it same (Label1.Text = "123")
Sandeep Mewara 28-Dec-10 8:46am    
I already shared the sample project and material. Read and look at them.
It's caching, do an IIS Reset and retry with new value just in case.
Sandeep is right, you forgot the thing in the code. You must take a look at this article which is well written.

Exploring Caching in ASP.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900