Namespace for web.client [Resolved]

Posted by Shitalr under ASP.NET on 9/6/2013 | Points: 10 | Views : 2146 | Status : [Member] | Replies : 2
which namespace i should use for web.client.




Responses

Posted by: Allemahesh on: 9/6/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You can use the using System.Net; for WebClient

Example:-

using System;
using System.Net;
using System.IO;

public class Test
{
public static void Main (string[] args)
{
if (args == null || args.Length == 0)
{
throw new ApplicationException ("Specify the URI of the resource to retrieve.");
}
WebClient client = new WebClient ();

// Add a user agent header in case the
// requested URI contains a query.

client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

Stream data = client.OpenRead (args[0]);
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();
Console.WriteLine (s);
data.Close ();
reader.Close ();
}
}

Happy Coding.

If it helps you or directs U towards the solution, MARK IT AS ANSWER.

Shitalr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/6/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
System.Net is the namwspace for WebClient

Refer the same here...
http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx
Sample : http://www.dotnetperls.com/webclient

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shitalr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response