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

Tip: Looking for answers? Try searching our database.

ASP.Net cache in VB class (not code-behind)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim S. - 15 Sep 2003 19:54 GMT
Hello,
    I am trying to use the ASP.Net cache in a regular
vb class (not a code-behind page).

I can easily insert an object into the Cache from the code-
behind with something like:

   Cache.Insert(cacheName, cacheData)

However when I try to put this in a new vb class, even
when I add the System.Web.Caching namespace, have the
project compile, I still get an "Object reference not set
to an instance of an object." error.

I've tried several variations, such as:
---
   Dim c As New System.Web.Caching.Cache
   c.Insert(cacheName, cacheData)

---
Stepping through in debug mode, c has been instantiated
and is {System.Web.Caching.Cache}.

Does anyone know what I could be doing wrong?

I've looked extensively at Microsoft's Caching Application
Block, but it doesn't seem to address this (it doesn't use
the ASP.Net cache).

Thanks,
Tim
John Saunders - 15 Sep 2003 22:14 GMT
> Hello,
> I am trying to use the ASP.Net cache in a regular
[quoted text clipped - 9 lines]
> project compile, I still get an "Object reference not set
> to an instance of an object." error.

Use HttpContext.Current.Cache.
Signature

John Saunders
Internet Engineer
john.saunders@surfcontrol.com

Tim S. - 16 Sep 2003 13:09 GMT
Thank you, that worked perfectly.

Tim

>-----Original Message-----
>> Hello,
[quoted text clipped - 12 lines]
>
>Use HttpContext.Current.Cache.

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.