Disable cache in Silverlight HttpWebRequest [duplicate]
My Silverlight4 app is hosted in ASP.NET MVC 2 web application. I do web request through HttpWebRequest class but it gives back a result previously cached. How to disable this caching behavior? There are some links which talks a开发者_运维问答bout HttpWebRequest in .NET but Silverlight HttpWebrequest is different. Someone suggested to add unique dummy query string on every web request, but I'd prefer more elegant solution. I also tried the following, but it didn't work:
_myHttpWebRequest.BeginGetRequestStream(new AsyncCallback(BeginRequest), new Guid());
In fact, by setting browser history settings it is possible to disable caching. See the following link: ASP.NET MVC with SQL Server backend returns old data when query is executed But asking a user to change browser settings is not an option for me.
The correct way to manage the caching is to adjust the server end so that correct values for HTTP headers that affect caching are sent.
For example in ASP.NET you might use the CacheControl
property on the Response
object
Response.CacheControl = HttpCacheability.NoCache;
精彩评论