Everything SharePoint and XAML

My continuous learning of SharePoint, XAML, Silverlight, Windows Phone 7, Windows 8, Office, VSTO, C#…

Silverlight: Avoid Caching When Using WebClient Class

Posted by Steve Pietrek on November 13, 2009

I have run into a puzzling issue the past few weeks. When using the WebClient class to retrieve SharePoint content, the content would not update when refreshing the page (F5) or refreshing the content (execute the WebClient object).

The issue was actually quite easy once I thought through what was happening. It also didn’t hurt that Fiddler only showed the initial query. Definitely a “Doh!” moment. To solve the issue, I pass another query string named “IgnoreCache” with the current date/time as the parameter.

public void FetchEvents() {
string sUrl = siteUrl + "_vti_bin/owssvr.dll?Cmd=Display&List=" + eventsListId + "&XMLDATA=TRUE&IgnoreCache=" + DateTime.Now;

WebClient sp = new WebClient();
sp.OpenReadCompleted += SpOpenReadEventsCompleted;
sp.OpenReadAsync(new Uri(sUrl));
}

More on Silverlight/SharePoint later…

Advertisements

One Response to “Silverlight: Avoid Caching When Using WebClient Class”

  1. […] Silverlight: Avoid Caching When Using WebClient Class (Steve Pietrek) […]

Sorry, the comment form is closed at this time.

 
%d bloggers like this: