Are you sure you are catching the same type of exception? Instead of WebException catch only Exception and see if you get a MessageBox
try { using (var myHttpWebResponse = (HttpWebResponse) httPrequestCreated.GetResponse()) { var streamResponse = myHttpWebResponse.GetResponseStream(); if (streamResponse != null) { var streamRead = new StreamReader(streamResponse); var readBuff = new Char[256]; var count = streamRead.Read(readBuff, 0, 256); while (count > 0) { var outputData = new String(readBuff, 0, count); finalResopnse += outputData; count = streamRead.Read(readBuff, 0, 256); } streamRead.Close(); streamResponse.Close(); myHttpWebResponse.Close(); } } } catch (Exception ex) { MessageBox.Show(string.format("this went wrong: {0}", ex.Message)); }
Change Watching you, I think you see that Exception is thrown before it is thrown into your catch block. On your VS, press Ctrl + Alt + E and make sure that the Throw Common Language Runtime Exceptions check is not checked
sebagomez Feb 26 '12 at 18:10 2012-02-26 18:10
source share