Windows. Web. Http. HttpClient. GetStringAsync always returns the same result, system. web. http

Source: Internet
Author: User

Windows. Web. Http. HttpClient. GetStringAsync always returns the same result, system. web. http

Today, when I tested the WP8.1 client of blog news, I found that the news on my computer has been updated. However, the mobile phone has not been updated, so it must have been a bug. So I created a Web test project and found that only the first request was sent. At first, I thought it was an MVVM problem. Later I found out that it was a problem with the HttpClient class.

HttpClient caches Get requests with the same Uri locally.

Solution:

1. Add a timestamp to querystring.

2. Add a Filter when creating HttpClient.

1 var filter = new HttpBaseProtocolFilter (); 2 filter. cacheControl. readBehavior = HttpCacheReadBehavior. mostRecent; 3 using (var client = new HttpClient (filter) 4 {5 var html = await client. getStringAsync (); 6}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.