Strange exception from HttpWebRequest

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);
 
G

Guest

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top