[英]How to clear json api response from windows phone 8.1
我正在开发Windows应用程序8.1。 我在页面中调用json api的地方说“ Page1”。 我的问题是,当我导航到另一个页面时说“ Page2”并返回到“ Page1”时,我从api中获取了相同的数据。 我发现当我再次回到Page1时,我的Web api被调用了,但是结果是从缓存中获取的,所以json数据没有更新。 我该如何克服这个问题。 任何建议都是最欢迎的。
我的Rest API调用代码为
var client = new HttpClient(); // Add: using System.Net.Http;
var response = await client.GetAsync(new Uri(url));
response.Headers.Add("Cache-Control", "no-cache");
var result = await response.Content.ReadAsStringAsync();
response.Dispose();
client.Dispose();
return ressult.
在调用网址中,只需添加一个随机参数,例如
string uri = string.format(http://www.myservice.com?time={0}",DateTime.Now);
var response = await client.GetAsync(new Uri(uri));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.