Blazor WebAssembly App with Individual User Accounts and Store user accounts in-app using gives no local user accounts

Viewed 3651

Creating a new Blazor WebAssembly App with Individual User Accounts and Store user accounts in-app using Visual Studio 2019 16.8.2 and .NET 5.0 gives no local user accounts.

enter image description here

Starting the app it says:

Before authentication will function correctly, you must configure your provider details in Program.cs

Program.cs:

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("#app");

        builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        builder.Services.AddOidcAuthentication(options =>
        {
            // Configure your authentication provider options here.
            // For more information, see https://aka.ms/blazor-standalone-auth
            builder.Configuration.Bind("Local", options.ProviderOptions);
        });

        await builder.Build().RunAsync();
    }
}

Clicking on Log in redirects to:

https://localhost:44444/authentication/login-failed

With the following message:

There was an error trying to log you in: 'Invalid response Content-Type: text/html, from URL: https:login.microsoftonline.com/.well-known/openid-configuration'

wwwroot -> appsettings.json looks like this:

{
  "Local": {
    "Authority": "https://login.microsoftonline.com/",
    "ClientId": "33333333-3333-3333-33333333333333333"
  }
}

https://aka.ms/blazor-standalone-auth leads to https://docs.microsoft.com/en-gb/aspnet/core/blazor/security/webassembly/?view=aspnetcore-3.1

Standalone Blazor WebAssembly apps seems to either require Azure Active Directory (AAD), Azure Active Directory B2C (AAD B2C) or another Identity Provider (IP).

Creating another application with Individual User Accounts and Store user accounts in-app gives ASP.NET Core Identity identity users and their own database.

2 Answers

You did not click self hosted so it wants to connect to and existing server.

enter image description here

You can remove that from Index.razor, that's a hard coded message from Index.razor page.

See the index.razor page here

Related