ResourceInvoker no longer used with single authentication Scheme, causing issues with ActionContext
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
Since .net 7 there is a [breaking change in the default authentication scheme](https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/7.0/default-authentication-scheme#new-behavior) that causes weird behavior when trying to use the `IActionContextAccessor`. If you only have 1 authentication scheme registered, it is automatically set as default schema, and the `ResouceInvoker` is not used. The `ResourceInvoker` is responsible for setting the `ActionContext` on the `IActionContextAccessor` dependency
Now we need to add a dummy schema to ensure the requests uses the `ResourceInvoker`
### Expected Behavior
Both with one or more authentication schemes registered, the `ResourceInvoker` should always be used
### Steps To Reproduce
A reproduction scenario can be found [here](https://github.com/PaulVrugt/actioncontextexample)
When you set a breakpoint in `Schema1.cs` on line 27, start the project and call the weatherforecast api, you can see that the `controllerContext` variable is null. Once you uncomment line 13 of `program.cs` and run the application again, the `controllerContext` variable is filled, and you can also see in the stacktrace (see `anything else`) that the `ResourceInvoker` is being used
### Exceptions (if any)
_No response_
### .NET Version
7.0.302
### Anything else?
this is the stacktrace when `controllerContext` is unavailable:

this is the callstack when `controllerContext` IS available (notice the `ResourceInvoker`, which is responsible for setting the `ActionContext` on the `IActionContextAccessor`):

Contributor guide
Assessment
This issue has not been assessed yet.