While browsing through the MS examples and Stackoverlow examples on how to handle exceptions generated by WebRequest
(HttpWebRequest
) and WebReponse
(HttpWebResponse
), I found a lot of examples that either handle exceptions or don't handle exceptions.
One example, I found very interesting was https://stackoverflow.com/a/137300/465292
using
within using
Another, example (from https://stackoverflow.com/a/3279967/465292)
var request = WebRequest.Create(requestUri) as HttpWebRequest;
if (request != null)
seems bogus to me, since no where in doc. http://msdn.microsoft.com/en-us/library/bw00b1dc%28v=vs.110%29.aspx, WebRequest.Create()
returns null
Microsoft own example http://msdn.microsoft.com/en-us/library/es54hw8e%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1, places both WebRequest
& WebReponse
in one try block.