title: Windows Ce Compact Framework HttpWebRequest
body: <p>i am trying to write some data on a <code>controller</code> using <code>rest api</code>.</p>
  
  <p>But something strange is happening. The first 1, 2, 3 writes are fine but than the application freezes and gets timeouts exceptions am i not closing something?</p>
  
  <p>This is the <code>code</code> below:</p>
  
  <pre><code>        WebRequest client = (read) ? HttpWebRequest.Create(ReadUri) : HttpWebRequest.Create(WriteUri);
          client.Method = "POST";
          client.ContentType = "application/json";
          CredentialCache creds = new CredentialCache();
          creds.Add(new Uri(WriteUri), "Basic", new NetworkCredential(*******));
          client.Credentials = creds;
          client.PreAuthenticate = true;
          ((HttpWebRequest)client).AllowWriteStreamBuffering = true;
          client.Timeout = 10000;
          //Skipped all data formatting
          byte[] data = Encoding.UTF8.GetBytes(req);
          client.ContentLength = data.Length;
          Stream dataStream = null; 
          try
          {
              //HttpWebResponse response = (HttpWebResponse)client.GetResponse();
              dataStream = client.GetRequestStream();
  
              dataStream.Write(data, 0, data.Length);
              dataStream.Flush();
              dataStream.Close();
              dataStream.Dispose();
              dataStream = null;
  
          }
          catch (WebException we)
          {
              string message = we.Message;
          }
          finally
          {
              client = null;
          }
  </code></pre>