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;
}
}
|