HttpResponseMessage.EnsureSuccessStatusCode Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Throws an exception if the IsSuccessStatusCode property for the HTTP response is false
.
public:
System::Net::Http::HttpResponseMessage ^ EnsureSuccessStatusCode();
public System.Net.Http.HttpResponseMessage EnsureSuccessStatusCode ();
member this.EnsureSuccessStatusCode : unit -> System.Net.Http.HttpResponseMessage
Public Function EnsureSuccessStatusCode () As HttpResponseMessage
Returns
The HTTP response message if the call is successful.
Exceptions
The HTTP response is unsuccessful.
Remarks
The EnsureSuccessStatusCode method throws an exception if the HTTP response was unsuccessful. In .NET Framework and .NET Core 2.2 and earlier versions, if the Content is not null
, this method will also call Dispose to free managed and unmanaged resources. Starting with .NET Core 3.0, the content will not be disposed.