Clients and settings¶
Run the complete page example.
After defining your API interface, you need to connect it to the service your app will use. These pages show how to create that client, apply request settings and make the client available to the rest of your app. Generated clients are the normal path. The creation and request-builder pages explain when runtime reflection is needed and how it affects trimming and Native AOT. They also explain who should dispose the HTTP client.
| Page | What you can do |
|---|---|
| Create a client | Create a generated client over a shared or new HttpClient, select an interface through Type, or use the reflection path when needed. |
| Settings | Set naming, serialization, request options and failure handling. |
| Dependency injection | Register generated clients, named transports and keyed clients. |
| Request builders | Select reflected methods by name and parameter types, or supply a request builder to client creation. |
The client example project
uses .NET 10, generated JSON metadata and local replies. Clients.RunAsync exercises generated clients.
The separate reflection project
exercises APIs that need runtime metadata and runtime compilation.
From the Refit checkout's src folder, run the reflection executable with:
dotnet run --project examples/Documentation/Clients/Reflection/Reflection.csproj -c Release
Use the AOT guide to publish generated examples as native code. Reflection examples use just-in-time compilation and do not demonstrate Native AOT compatibility.