I was encountering a problem where my WebResponse would timeout on the 3rd request. After a little research(quite a bit actually) I found that this is a ServicePointManager default setting(2). To avoid the ServicePoint defaults the recommendation was to close
the WebResponse which I wasn't doing. But now when I close the WebResponse my methods to receive the XmlReader from the WebResponse report that the "Request was aborted: Connection was closed unexpectedly" Below is my code:
csgnome
Member
85 Points
17 Posts
WebResponse closes xmlTextReader
Nov 03, 2003 06:41 PM|LINK
XmlTextReader oReader; WebRequest objWebRequest = WebRequest.Create(URL); objWebRequest.ContentType="text/xml"; WebResponse objWebResponse = objWebRequest.GetResponse(); Stream oReceiveStream = objWebResponse.GetResponseStream(); StreamReader oReadStream = new StreamReader(oReceiveStream,System.Text.Encoding.ASCII); oReader = new XmlTextReader(oReadStream); oReceiveStream.Flush(); oReader.WhitespaceHandling = WhitespaceHandling.None; objWebResponse.Close(); return oReader;The error doesn't happen on every request. Looks like it's the second or third. Thanks in advance - gnome