I read data from xml file like this :
StringBuilder str = new StringBuilder();
str.Append("<News>");
XDocument xmlDoc = XDocument.Load(path);
var q = xmlDoc.Descendants("news")
.Where(x => x.Descendants("language_id") != null && x.Descendants("language_id").First().Value == "2")
.Select(x => x);
foreach (var st in q)
{
str.Append(st.ToString(SaveOptions.DisableFormatting) + " ");
}
str.Append("</News>");
return str.ToString();
but I note recently that when the xml file updated. It still reads the data from the old one !!! I don’t know if it reads from a cashing copy or not .
When I reset the iis it updates the data .
How to fix this problem?
Quick hack.
Assuming
pathis a string containing a URL, changeto
This will defeat any intermediate caching that’s going on, and the use of the
?in the URL shouldn’t upset the server you are asking for data.(
Guid.NewGuid()is just a quick way to get a random string. You could easily use theRandomclass orDateTime.Now.Ticksin a similar way if you prefer.)