我正在使用此代码从URL获取返回字符串
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);
Run Code Online (Sandbox Code Playgroud)
在code.php这个样子的
<?php
$data = file_get_contents('code.txt');
echo $data;
?>
Run Code Online (Sandbox Code Playgroud)
问题是当我更改code.txt文件的内容时,该webClient.DownloadString()方法返回文件的旧内容code.txt。当我http://somesite.com/code.php在浏览器中打开URL时,它可以很好地工作。
任何解决方案将不胜感激!
我的问题似乎重复了,但我不太明白这里所说的是什么:C#WebClient disable cache
如果有人可以解释并提供示例代码,那就太好了!