Skip to content

Instantly share code, notes, and snippets.

@philcockfield
Created August 12, 2012 13:26
Show Gist options
  • Save philcockfield/3331798 to your computer and use it in GitHub Desktop.
Save philcockfield/3331798 to your computer and use it in GitHub Desktop.
WebRequest Premature call to Server (Node).
// Prepare the data.
var dataText = data.ToString();
var byteArray = dataText.ToByteArray();
// Setup the web-request.
var req = WebRequest.Create(url);
req.Method = "PUT";
req.ContentType = "Content-Type: application/json; charset=utf-8";
req.ContentLength = byteArray.Length;
// Process the stream.
Stream dataStream = req.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment