I have this .NET core web app that use multiple authentication schemes declared like that :
services.AddAuthentication("Scheme1")
.AddScheme<Scheme1Options, Scheme1Handler>("Scheme1", null)
.AddScheme<Scheme2Options, Scheme2Handler>("Scheme2", null)
.AddScheme<Scheme3Options, Scheme3Handler>("Scheme3", null);
In my controllers, I apply the appropriate scheme depending on what the controller does. This was working perfectly well in .net Core 2.2.
Then I updgraded to .net Core 3.1
I modified the startup.Configure() like that :
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
And now, I get a
InvalidOperationException: Endpoint /Index contains authorization metadata, but a middleware was not found that supports authorization. Configure your application startup by adding app.UseAuthorization() inside the call to Configure(..) in the application startup code. The call to app.UseAuthorization() must appear between app.UseRouting() and app.UseEndpoints(...).
for any controller that does not use the default middleware. It's like the 2 additional middleware were not recognized.
Any idea ?