Custom Search
Logiclabz
  • Home
  • Asp.Net
  • System.Net.WebClient difference in Asp.Net 1.1 and 2.0 (DownloadData vs DownloadString)

System.Net.WebClient difference in Asp.Net 1.1 and 2.0 (DownloadData vs DownloadString)

There is difference in webclient downloadstring in asp.net 2.0 and Downloaddata in asp.net 1.1 Downloaddata returns bytes, but downloadstring returns required string. In Asp.Net 1.1

 System.Net.WebClient wb = new System.Net.WebClient();
string url = "http://testurl.somedomainname.com/default.htm";
byte[] result = wb.DownloadData(url);
//To convert byte[] to string
string txt = System.Text.Encoding.GetEncoding("utf-8").GetString(result);
In Asp.Net 2.0
 System.Net.WebClient wb = new System.Net.WebClient();
string url = "http://testurl.somedomainname.com/default.htm";
txt = wb.DownloadString(url);



Leave a reply


Do you like this post?