liveBook · Manning

HTTP client

As explained in .NET MAUI in Action

HttpClient is a .NET class that sends HTTP requests and receives HTTP responses from network resources.

An HTTP client sends requests to network resources and receives responses. In .NET MAUI, HttpClient can retrieve JSON from REST APIs and deserialize it into C# objects for display. section 6.2.1 section 8.3

A typical MAUI data-loading flow is:

  • Store the API key, base URI, response models, collections, and HttpClient field. section 6.2.1
  • Create HttpClient with a base address, then assign the page as the binding context. section 6.2.1
  • Load genres and trending movies asynchronously when the page appears, using GetFromJsonAsync<T>. section 6.2.1
  • Bind the resulting collections to the UI and expose loading state while requests complete. section 6.2.1

REST APIs expose resources through HTTP verbs such as GET, POST, PUT, PATCH, and DELETE, with JSON commonly used for request and response payloads. Direct HttpClient calls work well for small applications; larger solutions may use autogenerated clients. section 8.3

Loading a REST resource

With an HttpClient whose base address is configured, an application can retrieve and deserialize a product in one asynchronous call: var product = await _httpClient.GetFromJsonAsync<Product>("product"); section 8.3

var product = await _httpClient.GetFromJsonAsync<Product>("product");

Inspect the compact GetFromJsonAsync example for a direct HttpClient-to-model request. section 8.3

How .NET MAUI in Action covers it

How deep it goes
Explains base-address setup, asynchronous JSON deserialization, and UI loading state, then contrasts direct calls with generated clients.
Examples
Demonstrates movie and genre retrieval in a MAUI app and product retrieval through GetFromJsonAsync.
What it assumes
Assumes basic .NET application structure while establishing REST verbs, JSON payloads, and typed response deserialization.
What you can do after
Build it from scratch by configuring HttpClient, calling REST endpoints, deserializing JSON, and binding results to a MAUI interface.
How it connects
Connects HttpClient with REST, JSON, Clean Architecture, NSwag, and Swagger UI.

Also explained in

Compare how 4 books explain HTTP client →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.