0

i have problem With HttpWebRequest.getResponse(). My try catch don't catch my response :/. Here is code: proxy and ports are good

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.google.com/");
        req.Proxy = new WebProxy(Host, Port);
        req.Method = "GET";
        req.KeepAlive = false;
        req.Timeout = 10000;
        req.ContentType = "text/xml";

      try
        {
            using (WebResponse response = req.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {

                }
            }

        }
        catch (WebException) { }
        catch (Exception){ }

Still getting window with error: https://i.stack.imgur.com/MriAT.jpg

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
Rafał Figura
  • 5,428
  • 1
  • 15
  • 20
  • What do you want to happen? What's the error message in English? – usr Aug 02 '14 at 16:34
  • The default connection has been closed. An unexpeced error occured while collecting. I want to check if proxy is working. Last time without threding this worked perfect now cant try and catch errors. However sometime i will get 404 exception or another one :/ – Rafał Figura Aug 02 '14 at 16:36

1 Answers1

3

It's likely that your try/catch is catching your exception; however, execution is breaking because you have first-chance exception debugging enabled. If you press "Continue", your program will proceed as expected. To alter this behaviour, just click the "Debug" menu, "Exceptions...", and untick the "Thrown" checkbox for CLR exceptions.

enter image description here

Douglas
  • 53,759
  • 13
  • 140
  • 188