473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XmlDataSource caches between page loads?

We are using an XML data source in the Page_Load event of an ASP.NET
page, like:

protected void Page_Load(object sender, EventArgs e)
{
// Retrieve XML from web service for product idea in URL
string sXML = GetXmlFromWebService(Request["ProductID"]);

XmlDataSource ds = new XmlDataSource();
ds.Data = sXML;

// Display data on web page
}

Now the weirdest thing is that the XML is actually *cached* between
page loads. The first product is shown correctly, but the next page
request always shows the first product. I've used the debugger to
verify that GetXmlFromWebService returns the correct XML for the new
product. But the XmlDataSource seems to ignore the new XML, even
though it's newly created.

Anyone have a clue what's going on?

TIA,
Wessel
Jun 27 '08 #1
8 2046
Hello Wessel,

Caching is enabled for XmlDataSource by default. U need to use XmlDataSource::EnableCaching
property to set false

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
WTWe are using an XML data source in the Page_Load event of an ASP.NET
WTpage, like:
WT>
WTprotected void Page_Load(object sender, EventArgs e)
WT{
WT// Retrieve XML from web service for product idea in URL
WTstring sXML = GetXmlFromWebService(Request["ProductID"]);
WTXmlDataSource ds = new XmlDataSource();
WTds.Data = sXML;
WT// Display data on web page
WT}
WTNow the weirdest thing is that the XML is actually *cached* between
WTpage loads. The first product is shown correctly, but the next page
WTrequest always shows the first product. I've used the debugger to
WTverify that GetXmlFromWebService returns the correct XML for the new
WTproduct. But the XmlDataSource seems to ignore the new XML, even
WTthough it's newly created.
WT>
WTAnyone have a clue what's going on?
WT>
WTTIA,
WTWessel
Jun 27 '08 #2
Hi Michael,

Thanks for your reply. We did indeed figure out how to fix the
behaviour, but we were wondering what causes it.

We are creating a new XmlDataSource with a new XML string. How does
the system decide to cache this? Does it assume every XmlDataSource on
every page only gets the exact same XML? Is the cache AppDomain wide,
or just for the particular ASP.NET thread?

Any tips or hyperlinks which might shed light on this matter
appreciated :)

-Wessel

On 27 apr, 16:44, Michael Nemtsev [MVP] <nemt...@msn.comwrote:
Hello Wessel,

Caching is enabled for XmlDataSource by default. U need to use XmlDataSource::EnableCaching
property to set false

---
WBR,
Michael *Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

WTWe are using an XML data source in the Page_Load event of an ASP.NET
WTpage, like:
WT>
WTprotected void Page_Load(object sender, EventArgs e)
WT{
WT// Retrieve XML from web service for product idea in URL
WTstring sXML = GetXmlFromWebService(Request["ProductID"]);
WTXmlDataSource ds = new XmlDataSource();
WTds.Data = sXML;
WT// Display data on web page
WT}
WTNow the weirdest thing is that the XML is actually *cached* between
WTpage loads. The first product is shown correctly, but the next page
WTrequest always shows the first product. I've used the debugger to
WTverify that GetXmlFromWebService returns the correct XML for the new
WTproduct. But the XmlDataSource seems to ignore the new XML, even
WTthough it's newly created.
WT>
WTAnyone have a clue what's going on?
WT>
WTTIA,
WTWessel
Jun 27 '08 #3
Hello Wessel,

http://msdn2.microsoft.com/en-us/lib...atasource.aspx

"The XmlDataSource automatically caches data when the EnableCaching property
is set to true, and the CacheDuration property is set to the number of seconds
that the cache stores data before the cache is invalidated. You can use the
CacheExpirationPolicy to further fine-tune the caching behavior of the data
source control.
"

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
WTHi Michael,
WT>
WTThanks for your reply. We did indeed figure out how to fix the
WTbehaviour, but we were wondering what causes it.
WT>
WTWe are creating a new XmlDataSource with a new XML string. How does
WTthe system decide to cache this? Does it assume every XmlDataSource
WTon every page only gets the exact same XML? Is the cache AppDomain
WTwide, or just for the particular ASP.NET thread?
WT>
WTAny tips or hyperlinks which might shed light on this matter
WTappreciated :)
WT>
WT-Wessel
WT>
WTOn 27 apr, 16:44, Michael Nemtsev [MVP] <nemt...@msn.comwrote:
WT>
>Hello Wessel,

Caching is enabled for XmlDataSource by default. U need to use
XmlDataSource::EnableCaching property to set false

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo

WTWe are using an XML data source in the Page_Load event of an
ASP.NET
WTpage, like:
WT>
WTprotected void Page_Load(object sender, EventArgs e)
WT{
WT// Retrieve XML from web service for product idea in URL
WTstring sXML = GetXmlFromWebService(Request["ProductID"]);
WTXmlDataSource ds = new XmlDataSource();
WTds.Data = sXML;
WT// Display data on web page
WT}
WTNow the weirdest thing is that the XML is actually *cached*
between
WTpage loads. The first product is shown correctly, but the next
page
WTrequest always shows the first product. I've used the debugger to
WTverify that GetXmlFromWebService returns the correct XML for the
new
WTproduct. But the XmlDataSource seems to ignore the new XML, even
WTthough it's newly created.
WT>
WTAnyone have a clue what's going on?
WT>
WTTIA,
WTWessel

Jun 27 '08 #4
http://msdn2.microsoft.com/en-us/lib...webcontrols.xm...
>
That's from the online documentation-- we've read that :)

Cashing an XML file makes sense, you could keep a list of filename +
parsed XML.

But how does it cache a random incoming string? What is the "key" of
the cache, to determine if a new "ds.Data = sXML;" statement hits the
cache?

If we'd load a from a different function, would it hit the cache? A
different page? A different AppDomain?
Jun 27 '08 #5
If it is that problematic, you could try just loading the XML into a DataSet
via ReadXml, and handle whatever caching you may need by yourself.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"Wessel Troost" wrote:
http://msdn2.microsoft.com/en-us/lib...webcontrols.xm...
That's from the online documentation-- we've read that :)

Cashing an XML file makes sense, you could keep a list of filename +
parsed XML.

But how does it cache a random incoming string? What is the "key" of
the cache, to determine if a new "ds.Data = sXML;" statement hits the
cache?

If we'd load a from a different function, would it hit the cache? A
different page? A different AppDomain?
Jun 27 '08 #6
Hi Peter,

Thanks for your reply. It's not problematic-- we've solved it-- it's
just that we are wondering how this caching works. So we can avoid
problems with it in the future.

Greetings,
Wessel

On 28 apr, 03:09, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
If it is that problematic, you could try just loading the XML into a DataSet
via ReadXml, and handle whatever caching you may need by yourself.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site:http://www.eggheadcafe.comhttp://pet...a.blogspot.com
*http://ittyurl.net

"Wessel Troost" wrote:
>http://msdn2.microsoft.com/en-us/lib...webcontrols.xm....
That's from the online documentation-- we've read that :)
Cashing an XML file makes sense, you could keep a list of filename +
parsed XML.
But how does it cache a random incoming string? What is the "key" of
the cache, to determine if a new "ds.Data = sXML;" statement hits the
cache?
If we'd load a from a different function, would it hit the cache? A
different page? A different AppDomain?
Jun 27 '08 #7
Wessel:

The XmlDataSource is meant to keep a synchronized version of an XML file in
memory. It will cache the data the CacheDuration time that you set (I
believe the default is indefinite) or when the XML file is modified.\

So I'm pretty sure that the "key" is the fully qualified file name, so since
you're not using a filename it loads the same data for all XmlDataSource
instances without a filename.

It looks like for what you're trying to do, you don't need to be using an
XmlDataSource as it is meant for the scenario described above. I think a
DataSet would be more suitable for your needs.

Hope that helps,
Fernando Rodriguez, MCP
"Wessel Troost" <we**********@gmail.comwrote in message
news:ac**********************************@y21g2000 hsf.googlegroups.com...
Hi Peter,

Thanks for your reply. It's not problematic-- we've solved it-- it's
just that we are wondering how this caching works. So we can avoid
problems with it in the future.

Greetings,
Wessel

On 28 apr, 03:09, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.comwrote:
If it is that problematic, you could try just loading the XML into a
DataSet
via ReadXml, and handle whatever caching you may need by yourself.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site:http://www.eggheadcafe.comhttp://pet...a.blogspot.com
http://ittyurl.net

"Wessel Troost" wrote:
>http://msdn2.microsoft.com/en-us/lib...webcontrols.xm...
That's from the online documentation-- we've read that :)
Cashing an XML file makes sense, you could keep a list of filename +
parsed XML.
But how does it cache a random incoming string? What is the "key" of
the cache, to determine if a new "ds.Data = sXML;" statement hits the
cache?
If we'd load a from a different function, would it hit the cache? A
different page? A different AppDomain?

Jun 27 '08 #8
Fernando,

Thanks for your reply, your post clarifies the caching. We tried the
dataset, but it doesn't support XPath data binding. (We're using XPath
queries in the .aspx markup file.)

Greetings,
Wessel

On 30 apr, 23:16, "Fernando Rodriguez, MCP"
<frodrig...@mcp.microsoft.comwrote:
Wessel:

The XmlDataSource is meant to keep a synchronized version of an XML file in
memory. It will cache the data the CacheDuration time that you set (I
believe the default is indefinite) or when the XML file is modified.\

So I'm pretty sure that the "key" is the fully qualified file name, so since
you're not using a filename it loads the same data for all XmlDataSource
instances without a filename.

It looks like for what you're trying to do, you don't need to be using an
XmlDataSource as it is meant for the scenario described above. I think a
DataSet would be more suitable for your needs.

Hope that helps,
Fernando Rodriguez, MCP

"Wessel Troost" <wesseltro...@gmail.comwrote in message

news:ac**********************************@y21g2000 hsf.googlegroups.com...
Hi Peter,

Thanks for your reply. It's not problematic-- we've solved it-- it's
just that we are wondering how this caching works. So we can avoid
problems with it in the future.

Greetings,
Wessel

On 28 apr, 03:09, Peter Bromberg [C# MVP]

<pbromb...@yahoo.NoSpamMaam.comwrote:
If it is that problematic, you could try just loading the XML into a
DataSet
via ReadXml, and handle whatever caching you may need by yourself.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.
Site:http://www.eggheadcafe.comhttp://pet...a.blogspot.com
http://ittyurl.net
"Wessel Troost" wrote:
http://msdn2.microsoft.com/en-us/lib...webcontrols.xm...
That's from the online documentation-- we've read that :)
Cashing an XML file makes sense, you could keep a list of filename +
parsed XML.
But how does it cache a random incoming string? What is the "key" of
the cache, to determine if a new "ds.Data = sXML;" statement hits the
cache?
If we'd load a from a different function, would it hit the cache? A
different page? A different AppDomain?
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: W. Kacy | last post by:
I am having trouble using XML in an ASP.NET 2.0 webform. Using ASP.NET 2.0 beta 2, I have created a blank web page in a C# website. I have added an XML file (soData.xml), structured as follows: ...
2
by: mike | last post by:
can somebody please show me some code that will let me populate a checkboxlist from the xmldatasource, and have the text property set to the names in the xml file thanks you can also email me...
0
by: Kurt Kubein | last post by:
Hi, I have this xmldoc linked to a xmldatasource in .Net 2.0 <MENUROOT title="Home" visible="true"> <MENU title="subnode_1" visible="true"> <MENUITEM title="leafnode_1" visible="true" />...
3
by: Brian | last post by:
Using external XML, I'm trying to build a quiz, but I can't seem to specify the DataSource for the RadioButtonList within a Repeater ItemTemplate. I've tried a number of approaches, but I haven't...
2
by: Zulander | last post by:
hi, i am trying to put a session variable in the DataFile of the XmlDataSource, but for some reason i am getting: Server tags cannot contain <% ... %constructs. <asp:XmlDataSource...
0
by: jim | last post by:
Hi, I have a TreeView control that sits on the MasterPage. All of my other webpages inherit from that Master Page. The Treeview receives it's data using an XMLDataSource that has it's DataFile...
1
by: zvickery | last post by:
Currently I have a project where multiple pages share a master page and also share a common XmlDataSource. Within the various pages, there are controls (such as DropDownLists) that I would like to...
4
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3)...
3
by: kayahr | last post by:
Hi there, I have a strange problem in Internet Explorer (IE6 and IE7). I'm writing a JavaScript application which allows the user to edit a photo composition. So when the user selects a photo then...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.