473,395 Members | 1,441 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,395 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 1635
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.