Blazor Default constructor not found for type Microsoft.AspNetCore.Components.Authorization.AuthorizeRouteView
Add @using Microsoft.AspNetCore.Components.Authorization
at the top of the App.razor file.
Add services for options and authorization to Program.Main (Client-side):
builder.Services.AddOptions();
builder.Services.AddAuthorizationCore();
Note: The following (Client-side):
services.AddBlazoredLocalStorage();
services.AddAuthorizationCore();
services.AddScoped<AuthenticationStateProvider,
ApiAuthenticationStateProvider>();
services.AddScoped<IAuthService, AuthService>();
Belongs in the client, not in the server, though at the end of the day its the same configuration...
Note: The following (Client-side):
services.AddScoped<AuthenticationStateProvider,
ApiAuthenticationStateProvider>();
Should be (Client-side):
services.AddScoped<ApiAuthenticationStateProvider>();
services.AddScoped<AuthenticationStateProvider>(provider => provider.GetRequiredService<ApiAuthenticationStateProvider>());
You should pay attention to order in the Startup class
Update:
Disabling the linker, as I've suggested in a comment below seems to be working. However, this should be a temporary solution. This is how you disable the linker: <BlazorLinkOnBuild>false</BlazorLinkOnBuild>
By disabling the linker, you prevent the removal of unused or un-referenced code, which may be the cause of the error... And by enabling the linker, you allow this. However, this code:
builder.Services.AddOptions();
builder.Services.AddAuthorizationCore();
should have prevented the linker from stripping off un-referenced logic. Still better, adding a custom AuthenticationStateProvider implementation in the Program class:
builder.Services.AddScoped<AuthenticationStateProvider,
ApiAuthenticationStateProvider>();
should have fixed this issue. Did you do that like that ?
Once again, disabling the linker is a temporary solution.