0

Have a ASMX web service that manipulates an XML file in a subfolder. This web service is called from another application to do the changing. I have no problem calling the service or making the changes to it. The problem is that the file contents that is returned from the XML is always the same. The web service changes it (verified from looking at the XML file itself). On another page I use XDocument to get the XML file and load the info into a gridview. The data that gets pushed to the gridview doesn't change even after the XML does. I have turned off caching for the page and viewstate for the gridview. What I can't figure out is how to get it so that the file itself always shows the most recent. Anyone know how to get it so that the XML will always be the latest? Thx.

FYI: IIS can't be touched unless it can be done on this app itself

Edit to show some code of the process that gets the XML file. My apologies in saying it was XDocument when in fact it is a XmlReader.

WebRequest.DefaultCachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
        var newXmlString = _xmlFile + "?nd=" +  + DateTime.Now.ToLongTimeString().Replace(" ", "").Replace(":", "");
        var serializer = new XmlSerializer(typeof(XmlDto.SubscriberData));
        using (var reader = XmlReader.Create(newXmlString))
        {
            var elements = (XmlDto.SubscriberData)serializer.Deserialize(reader);
            if (elements.Subscribers.Count > 0)
            {
                gridSubscribers.DataSource = elements.Subscribers.OrderByDescending(p => p.Name);
            }
            litTotalSubscribers.Text = elements.Subscribers.Count.ToString();
            gridSubscribers.DataBind();
        }

SOLVED or it seems to be after adding

RequestCacheLevel.NoCacheNoStore

it looks to be working correctly. Took awhile for the server to refresh itself and start using the new process but so far everything is being changed and things are coming back with the immediate changes.

4
  • Can you show some code? Dec 5, 2013 at 15:11
  • Like what sort of code would you be looking for? Dec 5, 2013 at 17:54
  • The code of this process Dec 6, 2013 at 8:01
  • Which process? The XDocument, the web service, etc? Here is a bit if useful. Dec 6, 2013 at 14:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.