如何禁用 WebClient 和 Windows Phone 7 的缓存 [英] How do you disable caching with WebClient and Windows Phone 7
问题描述
我正在调用 REST 网络服务,而移动应用正在从其缓存中检索结果,而不是前往服务器.
I am making a call to a REST web service and the mobile app is retrieving the results from its cache and not going to the server.
我看到了其他建议的修复(类似问题和类似问题2) 但Cache 属性在silverlight 4 中不可用.
I have seen other suggested fixes (similar issue and similar issue2) but the Cache property is not available in silverlight 4.
有没有人知道如何在 Windows Phone 7 上强制 Silverlight 4 发出请求而不访问缓存?
Does anyone have an idea of how to force silverlight 4 on windows phone 7 to make a request and not hit the cache?
推荐答案
虽然不理想,但一个简单的解决方案是发送类似字段垃圾"的内容,其值为 DateTime.Now
.这样,一个值总是全新的,永远不会被缓存.例如,如果您在标准查询中执行此操作:
Although not ideal, a easy solution is to send something like the field "junk" with the value DateTime.Now
. That way, a value is always brand new, and will never get cached. If you were doing this in a standard querysting for example:
"&junk=" + DateTime.Now;
这篇关于如何禁用 WebClient 和 Windows Phone 7 的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!