when you pull items from the cache, they are "object"'s ... you may have to
cast it to the appropriate type.
object o = null;
if (null!=Cache["key"])
{
o = Cache["key"];
}
DataSet ds = o as DataSet;
if(null!=ds)
{
Console.Writeline(ds.GetXml());
}
That of course .. is if you put a dataset into the cache.
There is a "smarter" way to do this:
see
http://spaces.msn.com/sholliday/ 10/24/2005 entry
it would be trivial to change this from a Session to an Application holder.
"Fred Nelson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi:
>
> This is probably a newby question however I can't figure it out!
>
> I'm trying to use application data caching in a web application. I have
> read an article on 4 guys from rolla that shows the following syntax:
>
> Write:
>
> Cache["key"] = value;
>
> Read:
>
> value = Cache["key"] - or - value = Cache.Get["key"]
>
> I can save the value (or I think I can) with the "write" statement / I
> am unable to get the values back with the "read":
>
>
> I receive the compile message:
>
> Cannot apply indexing with [] to an expression of type 'method group'
>
> Does anyone know how to make this work?
>
> Also: I would very much like to be able to read and update cache values
> in a class library. I have added the reference System.Web.Caching
> however this doesn't work - is there a way to do this?
>
> Thanks very much!
>
> Fred
>