Getting error when compiled Http webrequest

Posted by Afnan on Stack Overflow See other posts from Stack Overflow or by Afnan
Published on 2011-01-09T12:05:09Z Indexed on 2011/01/09 12:53 UTC
Read the original article Hit count: 263

Filed under:
|

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.

alt text

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));
                }
            }
        }

© Stack Overflow or respective owner

Related posts about c#

Related posts about httpwebrequest