views:

48

answers:

2

I have a admin page in asp.net that adds data to a database. This database is available as a JSON string to external websites, however, since it's a lot of data, the external websites cache this data locally.

I want to be able to ping the external websites to let them know the data has changed so they can referesh their cache. I figure I can setup an ASHX handler that receives a parameter telling them what data has changed, so they can both delete that data and refresh it.

The only part I'm not sure about is the best way to call this external page from my admin page. Do I just do a regular WebRequest and discard the result? or is there a simpler way to call a page from code when you don't need the response?

Basically I just want to "ping" this page, so it knows it needs to refresh.

thanks!

+1  A: 

You could have a flag set up in the database. That would turn this into a much simpler task.

If no alternative exists you can use the WebClient class:

using (var wc = new WebClient()) 
{
    wc.DownloadString(address);
}
ChaosPandion
I agree. it's up to the client to check for updates/cache invalidation.
dave thieben
I would normally agree, but there is one JSON string for every day of the year (that is how the data is cached) so I can't have the external website check for a flag on every request.the most practical approach seems to be to ping the client and let it know the data is expired. It's not ideal but performance-wise it's the best way I can come up with to automate it...
Josh
+1  A: 

If you just want to call the remote page, you can use the WebRequest class. http://msdn.microsoft.com/en-us/library/debx8sh9.aspx

WebRequest request = WebRequest.Create("http://my.domain.ext/page.ashx");
using(WebResponse response = request.GetResponse()) {
  response.Close();
}

If you want to do more advanced stuff a webservice would be more appropriate.

nxt