我有一个带有网络浏览器组件的表单,有一个触发页面重新加载的按钮,这是代码:
kiekmiestu = comboBox1.Text;
string nuoroda = "http://centrosokoladine.lt/PHP/generatorius.php?m=" + kiekmiestu;
webBrowser1.Navigate(nuoroda);
假设 kiemiestu 得到 teks 四个,所以 php 生成器在每次页面刷新时在 map 的随机位置生成 4 个城市,我的问题是当我第二次单击按钮时 WebBrowser1 似乎没有第二次导航,couse 页面没有'不改变。可能是缓存问题,如果已经显示,WebBrowser 不会导航到同一页面?
请您参考如下方法:
你可以试试webbrowser.refresh() MSDN :
private void refreshButton_Click(object sender, EventArgs e)
{
// Skip refresh if about:blank is loaded to avoid removing
// content specified by the DocumentText property.
if (!webBrowser1.Url.Equals("about:blank"))
{
webBrowser1.Refresh();
}
}
关于 webbrowser.Refresh() 的更多信息以及为什么导航不起作用:
The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The Refresh method forces the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.
要清除 wbbrowser 控件缓存,请考虑这篇文章:http://support.microsoft.com/kb/326201/de
