Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / July 2004

Tip: Looking for answers? Try searching our database.

Caching a user control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shell D00d - 23 Jun 2004 10:29 GMT
Hi,

I have written a user control that generates a menu depending on the
type of user that has logged in to my site. The information about the
user is stored in a cookie.

The control works great, but now I want it to be cached as it will
always be the same for a particular user group. So I tried adding an
OutputCache directive to the control with VaryByParam = "none". So far
so good. It gets displayed right on the first request, but once it
gets cached, it never shows up again. I've written all the code to
generate the menu within the Page_Load event of the control.
Obviously, that doesn't run until the cache expires.

What is the correct approach to cache the control so that it gets
displayed all the time, but is retrieved from the cache? How would I
use VaryByParam when I'm not using any values from querystring or a
form POST? All my variables are in the cookie.

Thanks in advance.
Saurabh Nandu - 12 Jul 2004 08:32 GMT
Hi,

I think you will have to implement Custom Caching, and then write appropriate code to ensure you look up the cookie to change the different cache copies.

Following links from the .NET SDK should help you do that.

[ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconcachingversionsofpagebasedoncustomstrings.htm]

[ ms-help://MS.NETFrameworkSDKv1.1/cpgenref/html/cpconoutputcache.htm ]

look at the VaryByCustom property

Signature

Regards,
Saurabh Nandu
Master C#, the easy way...
[ www.MasterCSharp.com ]

> Hi,
>
[quoted text clipped - 16 lines]
>
> Thanks in advance.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.