Thanks. However, when I set the connection property to "Keep-Alive", I got
the following exception: "Keep-Alive and Close may not be set with this
property."
I also tried setting the KeepAlive property to true, which made no
difference: I still got the "Stream was not writable" exception.
"Tu-Thach" <tu*****@antispam.ongtech.com> wrote in message
news:B2**********************************@microsof t.com...
Dan,
That is part of the HTTP protocol. After a Web request is made, the
underlying connection is closed unless the client specifies to keep it open
for a period of time. You can request the connection to stay open by
setting the Connection property of the HttpWebRequest object to
"Keep-alive".
Tu-Thach
----- Dan wrote: -----
I'm experimenting with HttpWebRequest. After I've created a request:
m_request = (HttpWebRequest) WebRequest.Create(uri);
I'd like to repeatedly send requests to the URI, as follows:
public void SendRequest(string body)
{
StreamWriter stream = new
StreamWriter(m_request.GetRequestStream(),Encoding .ASCII);
stream.Write(body);
stream.Close();
}
However, the second time I send the request I get the following
exception:
An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: Stream was not writable.
Does anybody know why that happens?
Thanks...
Dan