Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4170

Custom authentication works, but fails on refresh

$
0
0

I have implemented my own authentification in MyAuthenticationStateProvider which derives from AuthenticationStateProvider.

In program.cs, I register this as

builder.Services.AddScoped<AuthenticationStateProvider, MyAuthenticationStateProvider>(serviceProvider => serviceProvider.GetRequiredService<MyAuthenticationStateProvider>());builder.Services.AddScoped<MyAuthenticationStateProvider>();

This works, and my provider is getting called when entering pages with @attribute [Authorize]

The issue is only when I refresh the page in the browser which throws the exception

InvalidOperationException: Unable to find the required 'IAuthenticationService' service. Please add all the required services by calling 'IServiceCollection.AddAuthentication' in the application startup code.

So, I am setting it up well enough for it to work, but not well enough for it to support page reload (ctrl+R in edge). This is the only way it fails, but it does, and I am absolutely confused about why.


Viewing all articles
Browse latest Browse all 4170


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>