Hello.
Thank you all for the great work!!
I followed a tutorial from Chris Sainty about "Authentication with client-side Blazor using WebAPI and ASP.NET Core Identity" (https://github.com/chrissainty/AuthenticationWithClientSideBlazor) but with Blazor 3.2.0-preview1.20073.1.
It seems to me that Blazor 3.2 is using .NETStandard 2.1 and Microsoft.AspNetCore.Components.Authorization is build for 2.0 and therefore i get an errormassage saying
System.MissingMethodException: Default constructor not found for type Microsoft.AspNetCore.Components.Authorization.AuthorizeRouteView
Is there a plan to update this Nuget or do i have to downgrade to 3.1?
@Bernhard-Ninaus thanks for contacting us.
I don't think this issue is related to netstnadard 2.0 vs netstandard 2.1. We have tests in this area and I've tested this myself with 3.1.0-preview4.19579.2 which also targets netstandard 2.1. I'm not sure what is going on in your app, but It is not this.
The error you are seeing is likely due to a linking issue, try turning off the linker and see if that fixes the issue.
The error you are seeing is likely due to a linking issue, try turning off the linker and see if that fixes the issue.
Yep, that was it.
I should have thought about this!
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
in the projket file does the trick, for those who may need it.
Thank you!
@Bernhard-Ninaus disabling the linker should be a temporary solution. I think the root issue is probably that no type in the Microsoft.AspNetCore.Components.Authorization
namespace is directly referenced in the app and there is optimized/linked away.
For example, adding a custom AuthenticationStateProvider
implementation in the Program
class fixed this issue for me, as that results in the assembly not being stripped.
Got the same error message, but solved it by changing the order of my code from this
builder.Services.AddAuthorizationCore();
builder.Services.AddScoped<AuthenticationStateProvider, DummyAuthenticationStateProvider>();
to this
builder.Services.AddScoped<AuthenticationStateProvider, DummyAuthenticationStateProvider>();
builder.Services.AddAuthorizationCore();
Had a similar error with the AuthorizationOptions
had to add the following to get it working:
builder.Services.AddAuthorizationCore(options => { });
Without the action on the options I got an error that the AuthorizationOptions
is not registered with the DI.
I got the same problem at 3.2.0 preview1. But after I migrated to 3.1.0 preview4 everything is fine. It must something wrong with the component.
c#
builder.Services.AddAuthorizationCore(options => { });
This work for me.
I was following the tuition https://github.com/chrissainty/AuthenticationWithClientSideBlazor.
In that case, 3.1.0 preview4 is fine.
But in 3.2.0 preview1 you must add a options lambo
Interestingly enough, adding the empty lambda like simplerjiang didn't work for me. Neither did changing the order of the services. Turning the linker off is the only thing that worked that I've tried thus far.
Hello, i might be a bit over my head here, but i did experience the same issue, however i was able to resolve that by using "AddOptions();" in start up, so:
builder.Services.AddScoped<AuthenticationStateProvider, AuthProvider>();
builder.Services.AddOptions();
builder.Services.AddAuthorizationCore();
Most helpful comment
Interestingly enough, adding the empty lambda like simplerjiang didn't work for me. Neither did changing the order of the services. Turning the linker off is the only thing that worked that I've tried thus far.