Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2004, 09:58 AM
Authorized User
 
Join Date: Aug 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default using Cache

Below is a member function of one of my asp.net pages, which is called to get access to the latest version of an xml document on disk. The asp.net app is an intranet app that provides a GUI to change the xml document, which in turn drives another app (the xml doc does).

After I insert the xmldoc in cache, my cache object shows item count = 1 in the watch window. However, I cannot retrieve the object from cache either using Cache.Item or Cache.Get.

Cache.Get("xmlDoc") and Cache["xmlDoc"] return "Cannot find the method on the object instance." and do not throw any exception.

Cache.Item is not even available in intellisense.

When I expand the Cache object in watch window, the count is 1, but Item property is <cannot view indexed property>

I have added reference to System.Web.dll and I have imported System.Web.Caching namespace. Any help will be appreicated.

Thanks.


private string loadXMLDoc()
{
if(Cache.Get("xmlDoc") != null && this.xmlDoc !=null)
return "true";

string path = ConfigurationSettings.AppSettings.Get("XMLDoc");
this.xmlDoc = new XmlDocument();
try
{
if(Cache.Get("xmlDoc") != null)
{
this.xmlDoc = (XmlDocument)Cache.Get("xmlDoc");
return "true";
}
xmlDoc.Load(Server.MapPath(path));
Cache.Insert("xmlDoc",xmlDoc, new CacheDependency(Server.MapPath(path)));
return "true";
}
catch(System.Exception e)
{
return e.Message;
}
}
 
Old June 7th, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Do you call the add method anywhere when creating the Cached object? I see the insert, but I don't see the Add. Maybe it is requiring you to do that, so when you check to see if the object exists, if it doesn't, call the Add.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
about using cache benordz ASP.NET 2.0 Basics 2 April 25th, 2008 09:19 AM
mysql cache pc2006 MySQL 1 March 26th, 2007 07:42 AM
Cache problem jeanzz83 ASP.NET 1.0 and 1.1 Basics 1 January 3rd, 2006 12:36 PM
Cache problem alton Classic ASP Basics 3 September 6th, 2004 12:37 PM
cache pab006 Classic ASP Basics 3 January 22nd, 2004 05:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.