Strange exception from HttpWebRequest

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am getting the following exception *sporadically* when posting a
"multipart/form-data" request: "nable to read data from the transport
connection." Does anyone know what that means and what causes it? Here the
snippet of code where the error occurrs (m_Request is an HttpWebRequest):

stream = new BinaryWriter(m_Request.GetRequestStream());
stream.Write(parameterList);
stream.Flush();
if (m_BinaryUpload)
{
m_BinaryUploadFile.SendFile(stream);
stream.Write(m_BinaryUploadTail.ToCharArray());
stream.Flush();
}
}
finally
{
if (stream != null)
{
Tracer.WriteLine("ServletRequest.PostRequest", "Closing Http
Stream.", Tracer.TraceLevel.Debug);
stream.Close();
Tracer.WriteLine("ServletRequest.PostRequest", "After Closing Http
Stream.", Tracer.TraceLevel.Debug);
}
}
m_Response = (HttpWebResponse) m_Request.GetResponse();
Tracer.WriteLine("ServletRequest.PostRequest", "After
GetResponse.", Tracer.TraceLevel.Debug);
 
I already did that. Do you know what cause that particular exception?

Sergey Bogdanov said:
Try to set:

m_Request.AllowWriteStreamBuffering = true;

Also you can see there complete example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/httpcomm.asp



--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

I am getting the following exception *sporadically* when posting a
"multipart/form-data" request: "nable to read data from the transport
connection." Does anyone know what that means and what causes it? Here the
snippet of code where the error occurrs (m_Request is an HttpWebRequest):

stream = new BinaryWriter(m_Request.GetRequestStream());
stream.Write(parameterList);
stream.Flush();
if (m_BinaryUpload)
{
m_BinaryUploadFile.SendFile(stream);
stream.Write(m_BinaryUploadTail.ToCharArray());
stream.Flush();
}
}
finally
{
if (stream != null)
{
Tracer.WriteLine("ServletRequest.PostRequest", "Closing Http
Stream.", Tracer.TraceLevel.Debug);
stream.Close();
Tracer.WriteLine("ServletRequest.PostRequest", "After Closing Http
Stream.", Tracer.TraceLevel.Debug);
}
}
m_Response = (HttpWebResponse) m_Request.GetResponse();
Tracer.WriteLine("ServletRequest.PostRequest", "After
GetResponse.", Tracer.TraceLevel.Debug);
 
Back
Top