Hi,
I created a class that reads the contents of a webpage based on the response from the server, here's the vb.net code:
The problem is when the url is invalid then the streams aren't closed properly.Code:Dim wrq As HttpWebRequest Dim wres As HttpWebResponse Dim sr As StreamReader Dim s As Stream wrq = CType(WebRequest.Create(url), HttpWebRequest) Try wres = CType(wrq.GetResponse(), HttpWebResponse) sr = New StreamReader(wres.GetResponseStream()) strResponse = sr.ReadToEnd() Finally sr.Close() wres.Close() End Try




Reply With Quote