Disable Cache in Silverlight HttpWebRequest

My Silverlight4 application is hosted in an ASP.NET MVC 2 web application. I make a web request through the HttpWebRequest class, but it returns the result previously cached. How to disable this caching behavior? There are a few links that talk about HttpWebRequest in .NET, but Silverlight HttpWebrequest is different. Someone suggested adding a unique dummy query string for each web request, but I would prefer a more elegant solution. I also tried the following, but this did not work:

_myHttpWebRequest.BeginGetRequestStream(new AsyncCallback(BeginRequest), new Guid()); 

In fact, by setting your browser history settings, you can disable caching. See the following link: ASP.NET MVC with SQL Server backend returns old data when executing a query But asking a user to change browser settings is not an option for me.

+4
source share
2 answers

Ok, I found a more correct answer at the following link:

Disable browser cache for the entire ASP.NET website

+1
source

The right way to manage caching is to configure the end of the server to send the correct HTTP header values ​​that affect caching.

For example, in ASP.NET you can use the CacheControl property for a Response object

  Response.CacheControl = HttpCacheability.NoCache; 
+2
source

Source: https://habr.com/ru/post/1312632/


All Articles