[]
Represents the result of a web request, including the success status, the response content, any connection failure, and the HTTP status code.
public class WebRequestResult
Public Class WebRequestResult
class ResultWebHandler : IWebRequestHandler
{
public Task<WebRequestResult> GetAsync(string requestUri)
{
WebRequestResult result = new WebRequestResult
{
StatusCode = 200,
IsConnectionFailed = false,
ResponseContent = new byte[] { 1, 2, 3 }
};
return Task.FromResult(result);
}
}
IWebRequestHandler handler = new ResultWebHandler();
WebRequestResult result = await handler.GetAsync("https://example.com/data");
int statusCode = result.StatusCode;
| Name | Description |
|---|---|
| WebRequestResult() |
| Name | Description |
|---|---|
| IsConnectionFailed | Gets or sets a value indicating whether the web request failed due to a connection issue. |
| ResponseContent | Gets or sets the response content from the web request, if the request was successful. The content is stored as a byte array to preserve the original data format. |
| StatusCode | Gets or sets the HTTP status code of the web request. |