HttpResponseMessage.EnsureSuccessStatusCode Method ()

.NET Framework (current version)
 

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

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Return to top
Show: