title: C#: Handling WebClient "protocol violation"
body: <p>I need to read a location in my Router, but I get the following exception -</p>
  
  <pre><code>ServerProtocolViolation "The server committed a protocol violation. 
                          Section=ResponseHeader Detail=CR must be followed by LF"
  </code></pre>
  
  <p>This occurs when I use the <code>.DownloadString(url)</code> function. Is there any way to make <code>WebClient</code> ignore protocol violation? Searches in Google tell me I should set the <code>useUnsafeHeaderParsing</code> option somewhere. Can I do it through program? What's the catch if I use it?</p>
  
  <p>Edit: Attaching code -</p>
  
  <pre><code>    public Readlog() {
          WebClient wc = new WebClient();
  
          string url = @"http://192.168.0.1/setup.cgi?next_file=log.htm&amp;todo=cfg_init";
          Console.WriteLine(url);
          try {
              //wc.Headers.Add("User-Agent", "Mozilla/5.0(Windows; U; Windows NT 5.2; rv:1.9.2) Gecko/20100101 Firefox/3.6");
              wc.Credentials = new NetworkCredential("admin", "admin");
              //Next line causes exception System.Net.WebException
              //Message - "The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF"
              //May be I need to use useUnsafeHeaderParsing somehow to avoid that
              string result = wc.DownloadString(url);
              Console.WriteLine(result);
          } catch (WebException we) {
              System.Diagnostics.Trace.WriteLine(we.ToString());
          }
      }
  </code></pre>