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.
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應