Y
Young Cho
Hi,
I am trying to figure out how the Http POST works in .Net CF by using the
example in the MS book - .Net Compact Framework. However, I get the
following exception thrown when I compile the sample code from the book:
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred
in System.dll
Additional information: A blocking operation is currently executing
I am trying to run on a PPC 2003 Emulator in the .Net VS 2003. No SPs on
the emulator. The code from the .Net Compact Framework book is below and
the exception is thrown on the requestStream.Close(); line.
Any thoughts or suggestions? Thanks!
Young.
string url = https://{my server URL};
string postData = "{my POST data - XML}";
WebRequest req = WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "text/plain; charset=utf-8";
// Encode the data
byte[] encodedBytes = Encoding.UTF8.GetBytes(postData);
req.ContentLength = encodedBytes.Length;
// Write encoded data into request stream
Stream requestStream = req.GetRequestStream();
requestStream.Write(encodedBytes, 0, encodedBytes.Length);
requestStream.Close();
WebResponse result = req.GetResponse();
I am trying to figure out how the Http POST works in .Net CF by using the
example in the MS book - .Net Compact Framework. However, I get the
following exception thrown when I compile the sample code from the book:
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred
in System.dll
Additional information: A blocking operation is currently executing
I am trying to run on a PPC 2003 Emulator in the .Net VS 2003. No SPs on
the emulator. The code from the .Net Compact Framework book is below and
the exception is thrown on the requestStream.Close(); line.
Any thoughts or suggestions? Thanks!
Young.
string url = https://{my server URL};
string postData = "{my POST data - XML}";
WebRequest req = WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "text/plain; charset=utf-8";
// Encode the data
byte[] encodedBytes = Encoding.UTF8.GetBytes(postData);
req.ContentLength = encodedBytes.Length;
// Write encoded data into request stream
Stream requestStream = req.GetRequestStream();
requestStream.Write(encodedBytes, 0, encodedBytes.Length);
requestStream.Close();
WebResponse result = req.GetResponse();