-5

How I Download The WebPage Content Using winInet.dll

Code (from the comments):

url="http://links.casemakerlegal.com/states/TX/books/Case_Law/results?search[Cite]=359%20S.W.3d.%20856" Uri urlCheck = new Uri(url); 
WebClient wc = new WebClient(); 
wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); 
Stream data = wc.OpenRead(urlCheck); 
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
  • Use `WebClient` or `HttpClient`. – SLaks Feb 06 '13 at 03:36
  • I Already Used, But i'm getting "internal server error" thats why i go for wininet.dll library.... – Neeraj Kumar Feb 06 '13 at 03:38
  • ..that is an error on the website side.. – Simon Whitehead Feb 06 '13 at 03:39
  • Thank you sir for your instant reply.... But if it would have been server side error then the normal browsers like Firefox must have given the same reply... but there the link is perfectly working ... kindly help why the request from my program is rendered like this... is there anything i am missing at the security level or what else ? – Neeraj Kumar Feb 06 '13 at 03:44
  • 1
    How are we to know? You haven't provided any code.. – Simon Whitehead Feb 06 '13 at 03:45
  • my mistake sir, here is the code snippet that i have written url="www.blahblah.com" Uri urlCheck = new Uri(url); WebClient wc = new WebClient(); wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); Stream data = wc.OpenRead(urlCheck); StreamReader reader = new StreamReader(data); string s = reader.ReadToEnd(); – Neeraj Kumar Feb 06 '13 at 03:47
  • 1
    @NeerajKumar: Switching HTTP clients is guaranteed to not affect server errors. – SLaks Feb 06 '13 at 03:49
  • sir can you clear little more about it ... or if you have any example.. – Neeraj Kumar Feb 06 '13 at 03:50

1 Answers1

1

Try the code below. If it doesn't work.. it's definitely a server side issue:

string s;
using (WebClient wc = new WebClient()) {
    s = wc.DownloadString("http://www.blahblah.com"); // put your url here.
}
Simon Whitehead
  • 63,300
  • 9
  • 114
  • 138