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 / December 2003

Tip: Looking for answers? Try searching our database.

Output Cache Set From Codebehind?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
localhost - 21 Dec 2003 15:27 GMT
I have a single .cs that I use as a page template; it
creates several controls that are used by .aspx.cs pages
that inherit from it.

I would like to add output caching to this page template
class, so I can turn output caching on/off
programmatically.  Right now I can only find resources
that set output caching in the .aspx page itself, which
is not what I want to do.

How can I set output caching for a page completely in a
class file?

Thanks.
MSFT - 22 Dec 2003 03:45 GMT
Hi localhost,

Thank you for using Microsoft Newsgroup service. Based on your description,
your have wrote a custom page class which will be used as template for some
other pages. You want to add some code in the template page class so that
you can programmatically control the page's outputcaching. Please correct
me if my understanding of your problem is not accurate.

If my understanding is correct, my suggestion is that you may try out the
caching APIS in provided in .netframework for ASP.NET. Generally, to set
the page output caching, you may use the
<%@ OutputCache Duration="#ofseconds" Location="Any | Client | Downstream |
Server | None" Shared="True | False" VaryByControl="controlname"
VaryByCustom="browser | customstring" VaryByHeader="headers"
VaryByParam="parametername" %>
directive in a certain aspx page. And the dotnet framework also provided a
set of caching APIS for the user to programmatically set these attributes.
These API methos are accessible through the HttpResponse.Cache property,
which is accessible using Response.Cache syntax in the page's code-behind
class or code-declaration block. For example:

Response.Cache.SetCacheability(HttpCacheability.NoCache); // set the
Cacheability
Response.Cache.SetExpires( expireDate);    //set the expire time for the
outputcache
Response.Cache.SetNoServerCaching();    //stop all the origin cache for the
current response

.................

You can have a look at the following link for more information about the
APIS
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconsettingcacheabilit
yofpage.asp?frame=true

Please try out the preceding suggestion to see whether it helps.

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Steven Cheng[MSFT] - 24 Dec 2003 01:34 GMT
Hi localhost,

Have you had a chance to try out my suggestion or have you resolved the
problem? Please feel free to let
me know if you need any help, Thanks

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


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.