Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
EnsureSuccessStatusCode Method
Collapse the table of content
Expand the table of content

HttpResponseMessage.EnsureSuccessStatusCode Method

.NET Framework 4.6 and 4.5

Throws an exception if the IsSuccessStatusCode property for the HTTP response is false.

Namespace:  System.Net.Http
Assembly:  System.Net.Http (in System.Net.Http.dll)

public HttpResponseMessage EnsureSuccessStatusCode()

Return Value

Type: System.Net.Http.HttpResponseMessage
Returns HttpResponseMessage.
The HTTP response message if the call is successful.

The EnsureSuccessStatusCode method throws an exception if the HTTP response was unsuccessful. If the Content is not null, this method will also call Dispose to free managed and unmanaged resources.

.NET Framework

Supported in: 4.6, 4.5

.NET for Windows Phone apps

Supported in: Windows Phone 8.1
© 2015 Microsoft