1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

A question about URI in c#

Discussion in 'C, C++, C#' started by mrpega, Nov 1, 2008.

  1. mrpega

    mrpega Regular Member

    Joined:
    Sep 19, 2008
    Messages:
    352
    Likes Received:
    88
    Does for example declaring:

    Uri u = new Uri("http://www.google.com");

    actually means that the application has accessed the page like a real human has enter the url into browser?
     
  2. doczoidberg

    doczoidberg Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    173
    Likes Received:
    55
    Occupation:
    Student
    Location:
    Germany
    Uri is only a Data-Class.

    How do you access the web?

    What do you want to do?
     
  3. mrpega

    mrpega Regular Member

    Joined:
    Sep 19, 2008
    Messages:
    352
    Likes Received:
    88
    sorry i meant if i put :

    WebRequest http = HttpWebRequest.Create(url);
    HttpWebResponse response = (HttpWebResponse)http.GetResponse();
    Stream stream = response.GetResponseStream();

    after the uri declaration..thanks for the help!!
     
  4. doczoidberg

    doczoidberg Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    173
    Likes Received:
    55
    Occupation:
    Student
    Location:
    Germany
    hmm i don't know. I access websites via the webclient-class. This "simulates" the Browser...
     
  5. joejoe1234

    joejoe1234 Newbie

    Joined:
    Jan 8, 2008
    Messages:
    32
    Likes Received:
    5
    using (WebClient wc = new WebClient() )
    {
    wc.Proxy=null;
    wc.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

    //if authenticated add a credential set
    string userName="me@mysite.com";
    string password = "mypass";
    wc.Credentials = new NetworkCredential(userName, password);

    wc.DownloadData("http://yoursite.com/");
    }