473,382 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

.NET Web Caching

Tim
I'm building a .NET C# web application using web caching.
The Cache class only works when I'm using an aspx page. I
want this Caching logic to be in its own class file (.cs)
in another project so other developers can use it too.
I'm instaintiating the Cache class like this but the
methods do not work like this.

Cache webCache = new Cache();
webCache.Add(.......)

Does web caching have to happen in aspx pages only?

-Tim
Nov 17 '05 #1
2 1633
First of all, Tim, you don't want to create a new Cache object; it already
exists in the Application. When you reference an object from the HttpContext
of a Page from a class that doesn't derive from Page, you can grab it from
the HttpContext under which the class operates (which is from inside a
Page). Example:

System.Web.Caching.Cache myCache = System.Web.HttpContext.Current.Cache;
myCache.Add(...);

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Tim" <ti*******@bankofamerica.com> wrote in message
news:00****************************@phx.gbl...
I'm building a .NET C# web application using web caching.
The Cache class only works when I'm using an aspx page. I
want this Caching logic to be in its own class file (.cs)
in another project so other developers can use it too.
I'm instaintiating the Cache class like this but the
methods do not work like this.

Cache webCache = new Cache();
webCache.Add(.......)

Does web caching have to happen in aspx pages only?

-Tim

Nov 17 '05 #2
Tim
Thx Kevin! My application worked exactly the way you
indicated.

-Tim

-----Original Message-----
First of all, Tim, you don't want to create a new Cache object; it alreadyexists in the Application. When you reference an object from the HttpContextof a Page from a class that doesn't derive from Page, you can grab it fromthe HttpContext under which the class operates (which is from inside aPage). Example:

System.Web.Caching.Cache myCache = System.Web.HttpContext.Current.Cache;myCache.Add(...);

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Tim" <ti*******@bankofamerica.com> wrote in message
news:00****************************@phx.gbl...
I'm building a .NET C# web application using web caching. The Cache class only works when I'm using an aspx page. I want this Caching logic to be in its own class file (.cs) in another project so other developers can use it too.
I'm instaintiating the Cache class like this but the
methods do not work like this.

Cache webCache = new Cache();
webCache.Add(.......)

Does web caching have to happen in aspx pages only?

-Tim

.

Nov 17 '05 #3

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

Similar topics

15
by: olle | last post by:
Hi folks. I learning asp.net and compare it with traditional asp and Access-developing. The issue is this one: 1/I have this Ms Acceess adp-project application that works fine on my Ms Sql...
1
by: moko | last post by:
I want to know whether 'dataset caching' is at the client end , or the server ? Similarly is an aspx page caching at the server or client ? Are there any 'gotchas' with caching ?
0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
3
by: Janaka | last post by:
Hi All, I'm having a problem with Page Output caching on a page that contains a DataGrid. Basically the page pulls up some data for sales information from the DB. Some of this has to be...
1
by: Leo Muller | last post by:
I am impressed by the caching performance of .NET. However, there is one major obstacle that I haven't managed to solve yet. What I want to do is the following: I have a normal site, and a...
3
by: DC | last post by:
Hi, (ASP.Net 1.1) is it possible to (programmatically and globally) deactivate page fragment caching? We have only two scenarios, development stage where we want caching off and testing where we...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
2
by: George1776 | last post by:
All, I've recently upgraded our production ASP.NET/C# application from framework 1.1 to 2.0. Since then I've been plagued by out-of-memory errors and problems with the cache object (which may...
0
by: jason | last post by:
hi experts, support.microsoft.com/kb/917072 and http://msdn.microsoft.com/msdnmag/issues/06/07/WebAppFollies/ As pointed out in these articles, users might get session variables belong to...
4
by: Hermann | last post by:
My site is a bit slow showing the main page so I thought caching query result in PHP will improve performace. Then I read MySQL documentation and saw that MySQL does have a caching feature. So......
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.