Tuesday, April 10, 2012

Reading RSS feed

Recently while reading the data from the RSS feed, we faced an issue with the RSS not getting updated because of the Header cache. After analysis we found that its because of the caching on client server, we are not able to get the updated data.

To solve this we have tried many options, but the easiest option is to embed the querystring with GUID, which will make sure its always the fresh request.

Following is the sample code

string sSiteUrl = sFeedURL;
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;
Guid guid = Guid.NewGuid();
sSiteContent = webClient.DownloadString(sSiteUrl+"?guid="+guid.ToString());
webClient.Dispose();

No comments:

Post a Comment