I have this code
If there is an error i would expect it to not throw an error but just return a ""Code:Try Dim myWebRequest As HttpWebRequest = DirectCast(HttpWebRequest.Create(url), HttpWebRequest) myWebRequest.Method = "GET" myWebRequest.Timeout = (My.Settings.timeout) * 1000 Dim myWebResponse As HttpWebResponse = DirectCast(myWebRequest.GetResponse(), HttpWebResponse) Dim myWebSource As New StreamReader(myWebResponse.GetResponseStream()) myPageSource = myWebSource.ReadToEnd() myWebResponse.Close() myWebSource.Close() myWebRequest.Abort() Return myPageSource Catch ex As Exception Return "" End Try
But when in debug sometimes I get an error thrown at this line:
And it shows the dialog box. Is this because its in debug mode. Im quite sure this is not true. So why is it showing the error even the whole code is in a Try Catch loopCode:Dim myWebResponse As HttpWebResponse = DirectCast(myWebRequest.GetResponse(), HttpWebResponse)




Reply With Quote