Code example
private static WebClient CreateWebClient(string userId, string password)
{
if (string.IsNullOrEmpty(userId))
return new WebClient();
else
return new WebClient
{
Credentials = new NetworkCredential(userId, password)
};
}
public static string GetData(string userId, string password, string url)
{
using (WebClient client = CreateWebClient(userId, password))
{
client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
byte[] bytData = client.DownloadData(new Uri(url));
string download = Encoding.ASCII.GetString(bytData);
return download;
}
}
You just use or modified this code and add your code base though you can use that as generalize use from your applications. Code is self explanatory so you easily get everything.
Indetail you can visit
this