title: ProtocolError while calling HttpWebRequest.GetResponse()
body: <p>I have a page containing links to some files. </p>
  
  <p>I basically need to access the source of the page for parsing it then and obtaining all the hyperlinks to the files. </p>
  
  <p>My code is something like this (some piece of code I've found in many places on the net ..):</p>
  
  <pre><code>    "private static byte[] ReadImageFromUrl(string url)
      {
          var myReq = (HttpWebRequest)WebRequest.Create(url);
  
          myReq.Timeout = 10000;
  
          WebResponse myResp = myReq.GetResponse();
  
          Stream stream = myResp.GetResponseStream();
  
          List&lt;byte&gt; bytesList = new List&lt;byte&gt;();
  
          using (var br = new BinaryReader(stream))
          {
              try
              {
                  while (true)
                  {
                      var b = br.ReadByte();
                      bytesList.Add(b);
                  }
              }
              catch (Exception)
              {}
  
              br.Close();
          }
  
          myResp.Close();
  
          return bytesList.ToArray();
      }"
  </code></pre>
  
  <p>Now the problem is I get "System.Net.WebException: The remote server returned an error: (500) Internal Server Error." when calling "myReq.GetResponse()" - examining the error I see that the status is 'ProtocolError'. </p>
  
  <p>The response property of the WebException object contains some server error ..(although when opening it from the browser it opens correctly) ...also when I call this function with the url of one of my files I get the same ProtocolError status, but the 404 error ... </p>
  
  <p>Please give any hint how could I solve it... or any other possibility of accomplishing this task.</p>
  
  <p>Thanks ! </p>