Note that there are some explanatory texts on larger screens.

plurals
  1. POC# HttpWebRequest.GetResponse - how is StatusCode usage handled for a non-exception vs webexception response?
    primarykey
    data
    text
    <p>Can someone help clear up the usage of the "StatusCode" property in HttpWebResponse and WebException? </p> <p>For example it seems that if:</p> <p>a) there is no exception, then the HttpWebResponse will have a StatusCode that could have some values that indicate both: - success (e.g. OK, Accepted etc) - failure (e.g. UseProxy, RequestTimeout etc)</p> <p>b) there is a WebExeption throw, which itself has a response object that again has a StatusCode (which I assume is based on the same HttpStatusCode Enumeration.</p> <p><strong>Question 1</strong> - Is there any consistency in terms of what StatusCode's will trigger a WebException (and you'd pick up the detail within the exception), versus which would come back without an exception but you'd find out the result in the StatusCode of the response object?</p> <p><strong>Question 2</strong> - Or more specifically what is the pseduo code (or C# code itself) for trying to handle a httpWebRequest.GetResponse call such that you want to differentiate between the categories of responses for the user:</p> <ul> <li><p>proxy settings / proxy issue => so can tell user to fix proxy settings</p></li> <li><p>connectivity issue / web-server down => so user is aware of this </p></li> <li><p>server side error (e.g. server is there but there is an issue handling the request - e.g content not there) => so user can raise with website manager</p></li> <li><p>success case (and I assume this would be more than just the OK) => na (success case)</p></li> </ul> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload