C
chris-s
Hi folks,
I'm having problems getting HTTP 'Put' to work. I've got HTTP 'Get' to work
ok using a MS sample, but the 'PUT' method returns the following error:
"WebException
Unable to read data from the transport connection"
I'm just trying to connect to IIS on my local pc using a PPC device in a
dock on the network, not over active sync, although an ipaq on an active
sync connection gives the same error.
I have disabled my firewall and checked the virtual directory settings allow
write access and anonymous access.
Below is the code being used...
public void UploadFileBinary(string localFile, string uploadUrl)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);
req.Method = "PUT";
req.AllowWriteStreamBuffering = true;
// Retrieve request stream
Stream reqStream = req.GetRequestStream();
// Open the local file
FileStream rdr = new FileStream(localFile, FileMode.Open);
// Allocate byte buffer to hold file contents
byte[] inData = new byte[4096];
// loop through the local file reading each data block
// and writing to the request stream buffer
int bytesRead = rdr.Read(inData, 0, inData.Length);
while (bytesRead > 0)
{
reqStream.Write(inData, 0, bytesRead);
bytesRead = rdr.Read(inData, 0, inData.Length);
}
rdr.Close();
reqStream.Close();
req.GetResponse();
}
Any help/ideas greatly appreciated.
Chris
I'm having problems getting HTTP 'Put' to work. I've got HTTP 'Get' to work
ok using a MS sample, but the 'PUT' method returns the following error:
"WebException
Unable to read data from the transport connection"
I'm just trying to connect to IIS on my local pc using a PPC device in a
dock on the network, not over active sync, although an ipaq on an active
sync connection gives the same error.
I have disabled my firewall and checked the virtual directory settings allow
write access and anonymous access.
Below is the code being used...
public void UploadFileBinary(string localFile, string uploadUrl)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);
req.Method = "PUT";
req.AllowWriteStreamBuffering = true;
// Retrieve request stream
Stream reqStream = req.GetRequestStream();
// Open the local file
FileStream rdr = new FileStream(localFile, FileMode.Open);
// Allocate byte buffer to hold file contents
byte[] inData = new byte[4096];
// loop through the local file reading each data block
// and writing to the request stream buffer
int bytesRead = rdr.Read(inData, 0, inData.Length);
while (bytesRead > 0)
{
reqStream.Write(inData, 0, bytesRead);
bytesRead = rdr.Read(inData, 0, inData.Length);
}
rdr.Close();
reqStream.Close();
req.GetResponse();
}
Any help/ideas greatly appreciated.
Chris