I am using this code to get the return string from URL
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);
the code.php
looks like this
<?php
$data = file_get_contents('code.txt');
echo $data;
?>
The problem is when I change the contents of the code.txt
file, the webClient.DownloadString()
method returns the old contents of the code.txt
file. When I open the URL http://somesite.com/code.php
in a browser it works perfectly fine.
Any solutions will be appreciated!
My question seems to be duplicated but I don't really understand what is said here: C# WebClient disable cache
If anyone could explain and provide some example code it would be great!
Try disabling the cache on the WebClient
webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
MSDN Documentation on WebClient Cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With