所以,我今晚在这里看过几页。我试图从ComboBox中选择我的用户代理,并在WebBrowser控件中进行检查。它适用于第一个循环,但如果我更改ComboBox中的值并再次单击该按钮,则用户代理不会更改。如果我退出程序并从头开始,它会改变。 这有什么问题?
private void btnStartCash_Click(object sender, EventArgs e)
{
NavigateToSite();
}
private void NavigateToSite()
{
webAdFrame.Navigate("http://whatsmyuseragent.com/", null, null,
"User-Agent: " + cboUserAgent.SelectedItem);
}
private void AdProxy_Load(object sender, EventArgs e)
{
SetUserAgentEntries();
}
private void SetUserAgentEntries()
{
cboUserAgent.Items.Add("Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0");
cboUserAgent.Items.Add("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
cboUserAgent.Items.Add("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A");
cboUserAgent.Items.Add("Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16");
cboUserAgent.SelectedIndex = 0;
}