Getting error when compiled Http webrequest
- by Afnan
i have written a program to search value from google every thing works fine but first time when page is loaded then i encounter error.after words if i click any link it is working fine no errors further.
Code is as follow
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
string raw = "http://www.google.com/search?hl=en&q={0}&aq=f&oq=&aqi=n1g10";
string search = string.Format(raw, HttpUtility.UrlEncode(searchTerm));
//string search = "http://www.whatismyip.com/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(search);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
{
browserA = reader.ReadToEnd();
this.Invoke(new EventHandler(IE1));
}
}
}