No cache with HttpClient in Windows Phone 8

后端 未结 5 396
夕颜
夕颜 2020-12-03 18:40

I\'ve read that in order to disable caching while using get and post methods in HttpClient, I need to use a WebRequestHandler as my HttpClien

5条回答
  •  佛祖请我去吃肉
    2020-12-03 19:19

    This for windows phone to get fresh data instead of catching data

    Using(HttpClient httpClient = new HttpClient())
    {
        httpClient.DefaultRequestHeaders.IfModifiedSince = DateTimeOffset.Now;
        //your code goes here`enter code here`
    }
    

    another alternative is set

    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    

    in server page Page_Load if u get data from aspx page

提交回复
热议问题