Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Caching Problems

Caching Problems

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdesignhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brian Delahunty
    wrote on last edited by
    #1

    Hey All, I'm having a little trouble with caching in ASP.NET and I wonder if somebody could tell me if what I'm trying to do should work. From my understanding of the MSDN documentation it should but it doesn't seem to be so maybe I'm doing something wrong. I have an ASP.NET page that contains a number of custom controls but there is only 1 that I'm interested in caching but two controls are involved. 1: A header control with a drop down list (not being cached) 2: A menu control (certain items depend on the value in the drop down list in the header control)(trying to cache) The menu control has a public property called Location and I'm using programatic caching (attributes) and the Menu class is adorned with PartialCaching attribute as shown here:

    [PartialCaching(100, null, "Location", null)]
    public class Menu : System.Web.UI.UserControl
    {
    public string Location
    {
    get
    {
    return m_location;
    }
    set
    {
    m_location = value;
    }
    }

    .
    .
    .
    

    In the above attribute the third paramater is the VaryByControl paramater so it should in effect allow me to control cahcing of this control based on the value of the Location property. The Location property is being set by the page that contains this control and by debugging I see that the sequence of events that happens manages to se the Location property of the menu control before the OnInit is called in the menu control (Debugging confirmed that it is indeed being set correctly). My understanding is that the OnInit is called just after the viewstate data has been received but if I'm wrong and it's reinitialising the entire page then that is probably my problem but I can't find any info in the MSDN on exactly what it does. As far as I can see this should cause the caching to occour with the desired effect.. i.e. different caches dependent upon the value of the Location property that is set before the OnInit of the menu control is called.... What actually happens is the first time the page loads the menu control is cached and then servered from the cache for the next 100 seconds regardless of what I set the Location property of the control too... I though the point of VaryByControl was to deal with situations exactly like this? Am I missing something really simple here?? I don't normally do ASP.NET stuff so I'm not entirely sure of the sequenc

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups