Click or drag to resize

HttpClientExtensionsGetStringSafeAsync Method (HttpClient, Uri, ArgDictionary, LogActivity)

Sends a GET request to a Uri and returns the response as a string ensuring that the operation succeeded.

Namespace:  System.Net.Http
Assembly:  Neon.Common (in Neon.Common.dll) Version: 2.3.2
Syntax
public static Task<string> GetStringSafeAsync(
	this HttpClient client,
	Uri requestUri,
	ArgDictionary headers = null,
	LogActivity activity = null
)

Parameters

client
Type: System.Net.HttpHttpClient
The client.
requestUri
Type: SystemUri
The request URI.
headers (Optional)
Type: Neon.CollectionsArgDictionary
Optional request headers.
activity (Optional)
Type: Neon.DiagnosticsLogActivity
Optional LogActivity whose ID is to be included in the request.

Return Value

Type: TaskString
The response string.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HttpClient. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentNullExceptionThrown when a required argument is null.
SocketExceptionThrown for network connectivity issues.
HttpExceptionThrown when the server responds with an HTTP error status code.
See Also