How to implement both a user registration and log in in a blazor webassembly asp.net core 8 using Azure AA B2C

risto l 0 Reputation points
2023-11-21T13:48:50.3833333+00:00
I have followed this guidance:
Secure an ASP.NET Core Blazor WebAssembly standalone app with Azure Active Directory B2C.
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/standalone-with-azure-active-directory-b2c?view=aspnetcore-8.0
In the following section is mentioned that LoginDisplay component offer users to log in and register.

LoginDisplay component
The LoginDisplay component (Shared/LoginDisplay.razor) is rendered in the MainLayout component (Shared/MainLayout.razor) and manages the following behaviors:
For authenticated users:
Displays the current user name.
Offers a link to the user profile page in ASP.NET Core Identity.
Offers a button to log out of the app.
For anonymous users:
Offers the option to register.
Offers the option to log in.

In the LoginDisplay component is only one link
        <a href="authentication/login">Log in </a>
If I add this link and click it
        <a href="authentication/register"> Register</a>
I am directed /authentication/register page in the web assembly which says “Registration not supported”.
How I implement the register function so that I am directed to the Azure ad B2c to the endpoint https://mytenant.b2clogin.com/ mytenant.onmicrosoft.com/B2C_1_signin1

My appsettings.json is:
{
  "AzureAdB2C": {
    "Authority": "https://mytenant.b2clogin.com/mytenant.onmicrosoft.com/B2C_1_signin1",
    "ClientId": "xxxxx-xxxx…",
    "ValidateAuthority": false
  }
}

Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET Blazor
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-11-21T21:23:04.26+00:00

    just change the href to the azure register page for your site:

    <a href="https://mytenant./...">Register</a>

    note: the login code just redirects to the azure login page.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.