Skip to content

Connect to a site

angshu kar

Asked May 25, 2006, 3:18 PM EDT3 answers
Share
LinkedInX

Hi,

Any sites from which I can learn on how to connect to a site using C# and fetch info from it.

AK

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    hi

    u must add a com componenent named "web browser" in win app. , and use navigate method for binding a URL on it .
    0
  • 0
     hi ,
          there is no web browser control on com compenents of a windows application. Where i can get that control.
    0
  • 0

    private string myURL = "http://www.c-sharpcorner.com";

    public bool GetFromURL()

    Java
    {
    // Create a 'WebRequest' object with the specified url.
    WebRequest myWebRequest = WebRequest.Create(myURL);
    myWebRequest.Timeout = 10000;
    // Send the 'WebRequest' and wait for response.
    try
    {
    WebResponse myWebResponse = myWebRequest.GetResponse();
    // Obtain a 'Stream' object associated with the response object.
    Stream ReceiveStream = myWebResponse.GetResponseStream();
    // Encoding format.
    Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
    // Pipe the stream to a higher level stream reader with the required encoding format.
    StreamReader readStream = new StreamReader(ReceiveStream, encode);

    while (string line = readStream.ReadLine())

    C#
    {
    // do something with line;
    }
    readStream.Close();
    // Release the resources of response object.
    myWebResponse.Close();
    }
    catch (WebException) {  }
    return true;
    }
    0