Gets the URI of the Internet resource associated with the request.
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Threading;
public class MainClass{
public static void Main(){
WebRequest myWebRequest=WebRequest.Create("http://www.google.com");
Console.WriteLine("\nThe Uri that was requested is {0}",myWebRequest.RequestUri);
WebResponse myWebResponse=myWebRequest.GetResponse();
Stream streamResponse=myWebResponse.GetResponseStream();
Console.WriteLine("\nThe Uri that responded to the WebRequest is '{0}'",myWebResponse.ResponseUri);
StreamReader reader = new StreamReader (streamResponse);
string responseFromServer = reader.ReadToEnd ();
Console.WriteLine (responseFromServer);
reader.Close ();
streamResponse.Close ();
myWebResponse.Close ();
}
}
Related examples in the same category