我使用这段代码从URL获取返回的字符串。
问题在于当我更改
如果您有任何解决方案,将不胜感激!
我的问题似乎是重复的,但我并不真正理解这里所说的: C# WebClient disable cache 如果有人能够解释并提供一些示例代码,那就太棒了!
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);
code.php
看起来像这样
<?php
$data = file_get_contents('code.txt');
echo $data;
?>
问题在于当我更改
code.txt
文件的内容时,webClient.DownloadString()
方法会返回旧的 code.txt
文件内容。但是,当我在浏览器中打开 URL http://somesite.com/code.php
时,它可以完美地工作。如果您有任何解决方案,将不胜感激!
我的问题似乎是重复的,但我并不真正理解这里所说的: C# WebClient disable cache 如果有人能够解释并提供一些示例代码,那就太棒了!
webclient
中禁用缓存甚至切换到HttpWebRequest
吗? - Andrey Korneyev