Hello. I am trying to use caching to populate a datalist. The select
method of the associated objectdatasourc e calls up
GetRecipePageBy RecipeCatID() to request the proper data (I am using
custom paging at SQL level
so there is a paging idx as well). The code works fine when caching
is edited out.
Problem. The cache object is only created the first time around. When
the dtl ia refreshed, th HttpContext.cac he object always returns
nothing. What am I doing wrong (there is no application restart)?
Thks for your input.
Public Function GetRecipePageBy RecipeCatID(ByV al RecipeCatID As
Nullable(Of Integer), _
ByVal PageIndex As Nullable(Of Integer), ByVal NumRows As
Nullable(Of Integer), ByRef RecipeCount As Integer) _
As RecipeDataSet.t blRecipesDataTa ble
' Set key to get/set our cache'd data
Dim strCacheKey As String = "GetRecipePageB yRecipeCatID" &
RecipeCatID.ToS tring() & PageIndex.ToStr ing
If HttpContext.Cur rent.Cache(strC acheKey) IsNot Nothing
Then
Return CType(HttpConte xt.Current.Cach e(strCacheKey),
RecipeDataSet.t blRecipesDataTa ble)
Else
If Not RecipeCatID.Has Value Then RecipeCatID = 0
If Not PageIndex.HasVa lue Then PageIndex = 0
If Not NumRows.HasValu e Then NumRows = 4 ' Show 4
entries
If IsNothing(Recip eCount) Then RecipeCount = 0
Dim myDataSet As RecipeDataSet.t blRecipesDataTa ble =
Adapter.GetReci pePageByRecipeC atID(RecipeCatI D, PageIndex, NumRows,
RecipeCount)
HttpContext.Cur rent.Cache.Inse rt(strCacheKey,
myDataSet, Nothing, DateTime.Now.Ad dMinutes(30), TimeSpan.Zero)
Return myDataSet
End If
End Function 4 11900
HttpContext.Cur rent.Cache is only maintained for one request. its mainly
used for handlers to send data to each other. you want session.
-- bruce (sqlwork.com) ms******@bluewi n.ch wrote:
Hello. I am trying to use caching to populate a datalist. The select
method of the associated objectdatasourc e calls up
GetRecipePageBy RecipeCatID() to request the proper data (I am using
custom paging at SQL level
so there is a paging idx as well). The code works fine when caching
is edited out.
Problem. The cache object is only created the first time around. When
the dtl ia refreshed, th HttpContext.cac he object always returns
nothing. What am I doing wrong (there is no application restart)?
Thks for your input.
Public Function GetRecipePageBy RecipeCatID(ByV al RecipeCatID As
Nullable(Of Integer), _
ByVal PageIndex As Nullable(Of Integer), ByVal NumRows As
Nullable(Of Integer), ByRef RecipeCount As Integer) _
As RecipeDataSet.t blRecipesDataTa ble
' Set key to get/set our cache'd data
Dim strCacheKey As String = "GetRecipePageB yRecipeCatID" &
RecipeCatID.ToS tring() & PageIndex.ToStr ing
If HttpContext.Cur rent.Cache(strC acheKey) IsNot Nothing
Then
Return CType(HttpConte xt.Current.Cach e(strCacheKey),
RecipeDataSet.t blRecipesDataTa ble)
Else
If Not RecipeCatID.Has Value Then RecipeCatID = 0
If Not PageIndex.HasVa lue Then PageIndex = 0
If Not NumRows.HasValu e Then NumRows = 4 ' Show 4
entries
If IsNothing(Recip eCount) Then RecipeCount = 0
Dim myDataSet As RecipeDataSet.t blRecipesDataTa ble =
Adapter.GetReci pePageByRecipeC atID(RecipeCatI D, PageIndex, NumRows,
RecipeCount)
HttpContext.Cur rent.Cache.Inse rt(strCacheKey,
myDataSet, Nothing, DateTime.Now.Ad dMinutes(30), TimeSpan.Zero)
Return myDataSet
End If
End Function
I think you are mistaken
HttpContext.Cur rent.Cache is the same as Application.Cac he and lives as
Application.
HttpContext.Cur rent.Items is the one that lives only during that request's
lifetime....
George,.
"bruce barker" <no****@nospam. comwrote in message
news:un******** ******@TK2MSFTN GP02.phx.gbl...
HttpContext.Cur rent.Cache is only maintained for one request. its mainly
used for handlers to send data to each other. you want session.
-- bruce (sqlwork.com)
ms******@bluewi n.ch wrote:
>Hello. I am trying to use caching to populate a datalist. The select method of the associated objectdatasourc e calls up GetRecipePageB yRecipeCatID() to request the proper data (I am using custom paging at SQL level so there is a paging idx as well). The code works fine when caching is edited out.
Problem. The cache object is only created the first time around. When the dtl ia refreshed, th HttpContext.cac he object always returns nothing. What am I doing wrong (there is no application restart)? Thks for your input.
Public Function GetRecipePageBy RecipeCatID(ByV al RecipeCatID As Nullable(Of Integer), _ ByVal PageIndex As Nullable(Of Integer), ByVal NumRows As Nullable(Of Integer), ByRef RecipeCount As Integer) _ As RecipeDataSet.t blRecipesDataTa ble
' Set key to get/set our cache'd data Dim strCacheKey As String = "GetRecipePageB yRecipeCatID" & RecipeCatID.To String() & PageIndex.ToStr ing
If HttpContext.Cur rent.Cache(strC acheKey) IsNot Nothing Then Return CType(HttpConte xt.Current.Cach e(strCacheKey), RecipeDataSet. tblRecipesDataT able)
Else If Not RecipeCatID.Has Value Then RecipeCatID = 0 If Not PageIndex.HasVa lue Then PageIndex = 0 If Not NumRows.HasValu e Then NumRows = 4 ' Show 4 entries If IsNothing(Recip eCount) Then RecipeCount = 0
Dim myDataSet As RecipeDataSet.t blRecipesDataTa ble = Adapter.GetRec ipePageByRecipe CatID(RecipeCat ID, PageIndex, NumRows, RecipeCount) HttpContext.Cur rent.Cache.Inse rt(strCacheKey, myDataSet, Nothing, DateTime.Now.Ad dMinutes(30), TimeSpan.Zero) Return myDataSet End If End Function
On 29 , 14:36, msch-...@bluewin.ch wrote:
HttpContext.Cur rent.Cache.Inse rt(strCacheKey,
myDataSet, Nothing, DateTime.Now.Ad dMinutes(30), TimeSpan.Zero)
This problem may be caused by contradiction between the absolute and
the sliding expiration.
Try this:
HttpContext.Cur rent.Cache.Inse rt(strCacheKey, myDataSet, Nothing,
DateTime.Now.Ad dMinutes(30),
System.Web.Cach ing.Cache.NoSli dingExpiration)
or this:
HttpContext.Cur rent.Cache.Inse rt(strCacheKey, myDataSet, Nothing,
System.Web.Cach ing.Cache.NoAbs oluteExpiration , new
TimeSpan(0,30,0 ))
Regards,
Mykola http://marss.co.ua
Thanks for your replies.
I was able to solve the problem after I realized that the the system
was short on RAM (my system is limited to 770 MB RAM). So closing a
bunch of FireFox pages solved the issue. Caching works ok.
A nasty side-effect has however now creeped in: the
odsRecipeDet_Se lected event of the datalist's associated
ObjectDataSourc e (odsRecipeDet) which is automatically triggered for
"fresh" data does not fire for cached data. This event is used to
update the custom navigation hyperlinks of the datalist. How can I re-
enable this event for cached data?
Thanks again for any hints. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: George Ter-Saakov |
last post by:
What is HttpContext.Cache for ?
The usual HttpRequest lasts miliseconds.
Why would someone to cache anything?
We do have HttpContext.Items to keep any extra info during the request.
Can someone explain me the use of the HttpContext.Cache.
Thanks.
|
by: DesignerX |
last post by:
What is the difference between Page.Cache and HttpContext.Current.Cache? Do
these access the same thing? Is there any easy way to clear all items in the
cache?
TIA,
Stan
|
by: Mat |
last post by:
Hi,
I've stumbled onto a problem when using the caching object in ASP.Net.
I'm placing a static dataset to the cache as the data only changes
once a day. Whilst writing to the cache I'm using a lock using code
like below (just typed this in);
Cache thisCache = HttpContext.Current.Cache
lock(thisCache)
|
by: xzzy |
last post by:
A. I need to access: System.Web.HttpContext.Current.Cache
but get this error:
"Object reference not set to an instance of the object"
B. System.Web.HttpContext.Current.Cache is accessible outside of this
class.
|
by: Graham |
last post by:
Here is the problem:
In Application_Start() I am setting the cache thus:
HttpContext.Current.Cache = myObj;
In a subsequent page request, I am accessing the cache thus:
MyObj myObj = HttpContext.Current.Cache as MyObj;
| |
by: =?Utf-8?B?TWFydGlu?= |
last post by:
Hi
I have a component (vb.net class project) which is used by both a web app
and windows app. But it uses Web.HttpContext.Current.Cache , works fine
in the web app but refuses to work in the windows app, even with all the
correct references. Just gives and Null Reference error.
What needs to be done to get Web.HttpContext.Current.Cache to work in the
windows app environment?
Any help would be appreciated :)
|
by: =?Utf-8?B?emlubw==?= |
last post by:
in asp.net 2,
I load a dataset from the Cache object into a local object to use to perform
processing. I had been using httpcontext.current.cache and what I noticed is
sometime I'm not able to get the dataset out of the cache.
the application is under heavy hits, and is set to email me on every error.
and once or twice every month I get these error e-mail about this issue.
why does the HTTPContext.Current.Cache call work sometimes, while...
|
by: Madhur |
last post by:
Hello
I am delivering an asp.net 2.0 application to my customer. I need to know,
If I need to check for the condition of HttpContext.Current to be null
in my business logic. I have extensively used Cache and Session objects, and
currently I assume HttpContext.Current object to be existent.
Also, since I do not have this check, some of my unit test cases fail
because there is no HttpContext for them.
|
by: SpaceMarine |
last post by:
hello,
my web app form has many DropDownLists that pull their content from a
database. these calls are in a Business Access Layer, when first
checks the context's Cache object for existing copies. to do that, the
BAL needs to be aware of the user's HttpContext.
question: how expensive is it for each BAL method to instantiate the
current context, like so:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |