How to use same login page in multiple projects in blazor webassembly?

332 Views Asked by At

I have created 3 blazor webassembly projects, all projects are having the same styles. My problem is I am duplicating the Login page for all the projects.

Is there any option to use the same page in all projects?

If I try to use the Razor library, I can't access the AuthenticationStateProvider.

1

There are 1 best solutions below

0
On
  1. Add the AuthenticationStateProvider to the DI container in Program.cs in your WebAssembly.

  2. Inject IServiceProvider into your Razor Component in the Razor Library.

  3. Use IServiceProvider.GetService to get hold of the AuthenticationStateProvider.

The following link should help you finish the job.

How to use Authorization namespace in a shared Razor Class Library Project?