Why does the GET method replicate the first answer one by one?

I have a problem with the Get method on Windows Phone. When I have a Get method, I get some answer, and then I send a method that changes the response of the get method, and then I check the get method again, but still it gives me the same answer from the first Get (somehow it replicated Get a response from the first method). How can I change it?

Get code example:

HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(URLS.host); wr.Method = "GET"; wr.CookieContainer = cookieContainer; wr.BeginGetResponse(new AsyncCallback(GetRequestStreamCallbackListaStrategii), wr); 
+4
source share
2 answers

Sounds like a caching issue. Assuming that you do not control or do not want to change the response on the server side, you can try adding a random query string for each call and see if it fixes this. For example, set URLS.host to:

 URLS.host = String.Format("{0}&rnd={1}", URLS.host, Guid.NewGuid().ToString()); HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(URLS.host); 

Alternatively, you can try the solution from this post .

 HttpWebRequest request = HttpWebRequest.CreateHttp(url); if (request.Headers == null) { request.Headers = new WebHeaderCollection(); } request.Headers[HttpRequestHeader.IfModifiedSince] = DateTime.UtcNow.ToString(); 
+2
source

Try the following:

 wr.Headers["Cache-Control"] = "no-cache"; wr.Headers["Pragma"] = "no-cache"; 
+1
source

Source: https://habr.com/ru/post/1500916/


All Articles