Quantcast
Channel: System.Net.WebException HTTP status code - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by miniyou for System.Net.WebException HTTP status code

(I do realise the question is old, but it's among the top hits on Google.)A common situation where you want to know the response code is in exception handling. As of C# 7, you can use pattern matching...

View Article


Answer by Martin Liversage for System.Net.WebException HTTP status code

By using the null-conditional operator (?.) you can get the HTTP status code with a single line of code: HttpStatusCode? status = (ex.Response as HttpWebResponse)?.StatusCode;The variable status will...

View Article


Answer by Sergey for System.Net.WebException HTTP status code

You can try this code to get HTTP status code from WebException. It works in Silverlight too because SL does not have WebExceptionStatus.ProtocolError defined.HttpStatusCode...

View Article

Answer by pr0gg3r for System.Net.WebException HTTP status code

this works only if WebResponse is a HttpWebResponse.try{ ...}catch (System.Net.WebException exc){ var webResponse = exc.Response as System.Net.HttpWebResponse; if (webResponse != null &&...

View Article

Answer by LukeH for System.Net.WebException HTTP status code

Maybe something like this...try{ // ...}catch (WebException ex){ if (ex.Status == WebExceptionStatus.ProtocolError) { var response = ex.Response as HttpWebResponse; if (response != null) {...

View Article


Answer by JaredPar for System.Net.WebException HTTP status code

I'm not sure if there is but if there was such a property it wouldn't be considered reliable. A WebException can be fired for reasons other than HTTP error codes including simple networking errors....

View Article

System.Net.WebException HTTP status code

Is there an easy way to get the HTTP status code from a System.Net.WebException?

View Article
Browsing latest articles
Browse All 7 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>