HttpResponseMessage.EnsureSuccessStatusCode Método

Definição

Gera uma exceção se a propriedade IsSuccessStatusCode da resposta HTTP for false.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

Retornos

HttpResponseMessage

A mensagem da resposta HTTP se a chamada for bem-sucedida.The HTTP response message if the call is successful.

Exceções

A resposta HTTP for malsucedida.The HTTP response is unsuccessful.

Comentários

O EnsureSuccessStatusCode método lançará uma exceção se a resposta http não tiver sido bem-sucedida.The EnsureSuccessStatusCode method throws an exception if the HTTP response was unsuccessful. No .NET Framework e no .NET Core 2,2 e versões anteriores, se o Content não for null , esse método também chamará Dispose recursos gratuitos gerenciados e não gerenciados.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. A partir do .NET Core 3,0, o conteúdo não será Descartado.Starting with .NET Core 3.0, the content will not be disposed.

Aplica-se a