Documentation icon indicating copy to clipboard operation
Documentation copied to clipboard

Extend ASP.NET Core Integration documentation to reflect the parameter binding changes made in .NET 7

Open alistairjevans opened this issue 2 years ago • 0 comments

In .NET 7, when IServiceProviderIsService.IsService was introduced, the ASP.NET Core framework attempts to detect if something is a service, and if we indicate it is, that will be used as the source of binding, as opposed to the [FromBody] binding, which was the default before.

In Autofac rules, all collections are valid services (but with an empty set if no registrations have been made), so from .NET 7 on, ASP.NET Core will inject empty collections from Autofac instead of binding the body content.

We should add to our docs for ASP.NET Integration to detail this point and indicate that users should be explicit with [FromBody] where appropriate to prevent automatic service injection.

See https://github.com/autofac/Autofac.Extensions.DependencyInjection/issues/114

alistairjevans avatar Jan 03 '24 12:01 alistairjevans