HighTechTalks DotNet Forums  

System.Web.Caching.Cahe doesn't work?Hi,

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss System.Web.Caching.Cahe doesn't work?Hi, in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
cheloman12
 
Posts: n/a

Default System.Web.Caching.Cahe doesn't work?Hi, - 02-23-2006 , 08:30 AM






Hi,
I'm using System.Web.Caching.Cahe to mantain a datatable object in an
asp.net user control.
this is de code i'm using:

//In the load event call LoadData method

protected void Page_Load(object sender, EventArgs e)
{
LoadData();
this.DataBind();
}

//In LoadData brings a datatable from database and inserts it to the cache
object if it doesn't exist previously. Later it should by retrieved from the
cache object.

private void LoadData()
{
if (!this.Page.IsPostBack || Cache["Data"] == null)
{
Interfaz.Datos oInterfaz = new Interfaz.Datos();
dtData = oInterfaz.BringData(UserID);
Cache.Insert("Data", dtData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout));
}
else
{
dtData = (DataTable)Cache["Data"];
}
dvData = dtData.DefaultView;
gvData.DataSource = dvData;
}

The problem is that the second time the page executes, Cache["Data"]
contains null.

I use this concept of caching from asp.net 1.1 and it works fine.

Someone knows why cache loses its objects?

Best Regards
Marcelo


Reply With Quote
  #2  
Old   
cheloman12
 
Posts: n/a

Default RE: System.Web.Caching.Cahe doesn't work?Hi, - 02-23-2006 , 10:27 AM






Hi Again,

I've forgot to say that the control is in an aspx page that work with a
master page.

I've just use the same code in an aspx page without the master page and the
cache runs ok.

is this a bug? because i haven't seen any KB about this behavior.

Best Regards

Marcelo

"cheloman12" wrote:

Quote:
Hi,
I'm using System.Web.Caching.Cahe to mantain a datatable object in an
asp.net user control.
this is de code i'm using:

//In the load event call LoadData method

protected void Page_Load(object sender, EventArgs e)
{
LoadData();
this.DataBind();
}

//In LoadData brings a datatable from database and inserts it to the cache
object if it doesn't exist previously. Later it should by retrieved from the
cache object.

private void LoadData()
{
if (!this.Page.IsPostBack || Cache["Data"] == null)
{
Interfaz.Datos oInterfaz = new Interfaz.Datos();
dtData = oInterfaz.BringData(UserID);
Cache.Insert("Data", dtData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout));
}
else
{
dtData = (DataTable)Cache["Data"];
}
dvData = dtData.DefaultView;
gvData.DataSource = dvData;
}

The problem is that the second time the page executes, Cache["Data"]
contains null.

I use this concept of caching from asp.net 1.1 and it works fine.

Someone knows why cache loses its objects?

Best Regards
Marcelo


Reply With Quote
  #3  
Old   
demi
 
Posts: n/a

Default Re: System.Web.Caching.Cahe doesn't work?Hi, - 02-24-2006 , 12:25 PM



I'm having a similar problem. To investigate, I added a callback method
to be called when the cache was removed and I wrote out the "Reason".
It was underused. It seems that in XP on my machine, if I'm running
other apps including VS2005, asp.net thinks the memory is low and it
free's up my cache item pretty much instantantly. I have 1GB of memory
so I'm not sure what exactly the problem it and the cache item is not
that big. If anyone knows how to fix this, I'd appreciate some advice.

cheloman12 wrote:
Quote:
Hi,
I'm using System.Web.Caching.Cahe to mantain a datatable object in an
asp.net user control.
this is de code i'm using:

//In the load event call LoadData method

protected void Page_Load(object sender, EventArgs e)
{
LoadData();
this.DataBind();
}

//In LoadData brings a datatable from database and inserts it to the cache
object if it doesn't exist previously. Later it should by retrieved from the
cache object.

private void LoadData()
{
if (!this.Page.IsPostBack || Cache["Data"] == null)
{
Interfaz.Datos oInterfaz = new Interfaz.Datos();
dtData = oInterfaz.BringData(UserID);
Cache.Insert("Data", dtData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout));
}
else
{
dtData = (DataTable)Cache["Data"];
}
dvData = dtData.DefaultView;
gvData.DataSource = dvData;
}

The problem is that the second time the page executes, Cache["Data"]
contains null.

I use this concept of caching from asp.net 1.1 and it works fine.

Someone knows why cache loses its objects?

Best Regards
Marcelo


Reply With Quote
  #4  
Old   
kevyou
 
Posts: n/a

Default Re: System.Web.Caching.Cahe doesn't work?Hi, - 02-28-2006 , 11:30 AM



i'm having the same problem in web services, the second call see's my cached objects removed. But interestingly I set test string to the Cache (="ttt")
and that stays 'live'
Changing to Application["cacheobject"]=object keeps the cache items alive as expected, so I assume something is desperately wrong with the Cache object.
In debug mode just before I access the Cache object for the secod time it is still in there, but when I do object o = (object) Cache["cacheobject"] it returns Null!!!

Quote:
I'm having a similar problem. To investigate, I added a callback method
to be called when the cache was removed and I wrote out the "Reason".
It was underused. It seems that in XP on my machine, if I'm running
other apps including VS2005, asp.net thinks the memory is low and it
free's up my cache item pretty much instantantly. I have 1GB of memory
so I'm not sure what exactly the problem it and the cache item is not
that big. If anyone knows how to fix this, I'd appreciate some advice.

cheloman12 wrote:
Hi,
I'm using System.Web.Caching.Cahe to mantain a datatable object in an
asp.net user control.
this is de code i'm using:

//In the load event call LoadData method

protected void Page_Load(object sender, EventArgs e)
{
LoadData();
this.DataBind();
}

//In LoadData brings a datatable from database and inserts it to the cache
object if it doesn't exist previously. Later it should by retrieved from the
cache object.

private void LoadData()
{
if (!this.Page.IsPostBack || Cache["Data"] == null)
{
Interfaz.Datos oInterfaz = new Interfaz.Datos();
dtData = oInterfaz.BringData(UserID);
Cache.Insert("Data", dtData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout));
}
else
{
dtData = (DataTable)Cache["Data"];
}
dvData = dtData.DefaultView;
gvData.DataSource = dvData;
}

The problem is that the second time the page executes, Cache["Data"]
contains null.

I use this concept of caching from asp.net 1.1 and it works fine.

Someone knows why cache loses its objects?

Best Regards
Marcelo


___
Newsgroups brought to you courtesy of www.dotnetjohn.com


Reply With Quote
  #5  
Old   
kevyou
 
Posts: n/a

Default Re: System.Web.Caching.Cahe doesn't work?Hi, - 02-28-2006 , 12:27 PM



definetly memory problems, my 1GB XP machine needed a reboot after my problems today figuring this out (2005 ide refused to start web service with problems attaching debugger).
All previous observations about cache entries dissapearing do not occur now.
Seems like the development environment is not keeping things 'clean'.

Quote:
i'm having the same problem in web services, the second call see's my cached objects removed. But interestingly I set test string to the Cache (="ttt")
and that stays 'live'
Changing to Application["cacheobject"]=object keeps the cache items alive as expected, so I assume something is desperately wrong with the Cache object.
In debug mode just before I access the Cache object for the secod time it is still in there, but when I do object o = (object) Cache["cacheobject"] it returns Null!!!

I'm having a similar problem. To investigate, I added a callback method
to be called when the cache was removed and I wrote out the "Reason".
It was underused. It seems that in XP on my machine, if I'm running
other apps including VS2005, asp.net thinks the memory is low and it
free's up my cache item pretty much instantantly. I have 1GB of memory
so I'm not sure what exactly the problem it and the cache item is not
that big. If anyone knows how to fix this, I'd appreciate some advice.

cheloman12 wrote:

___
Newsgroups brought to you courtesy of www.dotnetjohn.com


Reply With Quote
  #6  
Old   
Manso
 
Posts: n/a

Default Re: System.Web.Caching.Cahe doesn't work?Hi, - 03-06-2006 , 04:04 PM



Did you manage to nail down the problem? Are you running development web
server or IIS? We're also experiencing problems where cache.insert doesn't
stick in the cache. Very frustrating.

Thanks,
Manso

"demi" wrote:

Quote:
I'm having a similar problem. To investigate, I added a callback method
to be called when the cache was removed and I wrote out the "Reason".
It was underused. It seems that in XP on my machine, if I'm running
other apps including VS2005, asp.net thinks the memory is low and it
free's up my cache item pretty much instantantly. I have 1GB of memory
so I'm not sure what exactly the problem it and the cache item is not
that big. If anyone knows how to fix this, I'd appreciate some advice.

cheloman12 wrote:
Hi,
I'm using System.Web.Caching.Cahe to mantain a datatable object in an
asp.net user control.
this is de code i'm using:

//In the load event call LoadData method

protected void Page_Load(object sender, EventArgs e)
{
LoadData();
this.DataBind();
}

//In LoadData brings a datatable from database and inserts it to the cache
object if it doesn't exist previously. Later it should by retrieved from the
cache object.

private void LoadData()
{
if (!this.Page.IsPostBack || Cache["Data"] == null)
{
Interfaz.Datos oInterfaz = new Interfaz.Datos();
dtData = oInterfaz.BringData(UserID);
Cache.Insert("Data", dtData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout));
}
else
{
dtData = (DataTable)Cache["Data"];
}
dvData = dtData.DefaultView;
gvData.DataSource = dvData;
}

The problem is that the second time the page executes, Cache["Data"]
contains null.

I use this concept of caching from asp.net 1.1 and it works fine.

Someone knows why cache loses its objects?

Best Regards
Marcelo



Reply With Quote
  #7  
Old   
Manso
 
Posts: n/a

Default RE: System.Web.Caching.Cahe doesn't work?Hi, - 03-06-2006 , 05:00 PM



Please see:

http://msdn.microsoft.com/newsgroups...33e&sloc=en-us

"cheloman12" wrote:

Quote:
Hi,
I'm using System.Web.Caching.Cahe to mantain a datatable object in an
asp.net user control.
this is de code i'm using:

//In the load event call LoadData method

protected void Page_Load(object sender, EventArgs e)
{
LoadData();
this.DataBind();
}

//In LoadData brings a datatable from database and inserts it to the cache
object if it doesn't exist previously. Later it should by retrieved from the
cache object.

private void LoadData()
{
if (!this.Page.IsPostBack || Cache["Data"] == null)
{
Interfaz.Datos oInterfaz = new Interfaz.Datos();
dtData = oInterfaz.BringData(UserID);
Cache.Insert("Data", dtData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout));
}
else
{
dtData = (DataTable)Cache["Data"];
}
dvData = dtData.DefaultView;
gvData.DataSource = dvData;
}

The problem is that the second time the page executes, Cache["Data"]
contains null.

I use this concept of caching from asp.net 1.1 and it works fine.

Someone knows why cache loses its objects?

Best Regards
Marcelo


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.