dotnet / dotnet/dotnet-api-docs

Example code in ITypedHttpClientFactory<TClient> Interface page is broken

Open
#8,305 1 comment 1 reaction 0 assignees View on GitHub
area-System.Net Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/Microsoft.Extensions.Http/ITypedHttpClientFactory%601.xml

```c#
// in Controllers/HomeController.cs
public class HomeController : ControllerBase(IApplicationBuilder app, ExampleClient exampleClient)
{
private readonly ExampleClient _exampleClient;

public HomeController(ExampleClient exampleClient)
{
_exampleClient = exampleClient;
}

public async Task Index()
{
var response = await _exampleClient.GetAsync("/helloworld");
var text = await response.Content.ReadAsStringAsync();
return Content("Remote server said: " + text, "text/plain");
};
}
```

1.) I don't think the `ControllerBase(IApplicationBuilder app, ExampleClient exampleClient)` syntax exists
2.) `ExampleClient` does not have a `GetAsync` method
3.) semicolon after `Index()`'s method body

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.