Integrating Azure B2C Authentication with .NET Framework 4.6.2

599 Views Asked by At

I'm working on a legacy project that uses .NET Framework 4.6.2, and I need to integrate Azure AD B2C for user authentication. While I've successfully set up Azure B2C and implemented the authentication with .NET Core, I'm struggling to achieve the same integration with .NET Framework 4.6.2.

I'd appreciate guidance on how to start this integration, as well as any code examples, tutorials, or best practices that can help me set up Azure B2C authentication with .NET Framework 4.6.2. Even a simple code snippet for a login button would be extremely helpful. I understand that this is an older technology stack, but I believe it's still feasible.

1

There are 1 best solutions below

2
On BEST ANSWER

Thanks @Panagiotis Kanavos and jdweng for the comments.

As mentioned by Panagiotis Kanavos, we have a MSDoc which explains the clear steps to Integrate ADB2C in a Framework Application (GitHub samples).

guidance on how to start this integration

  • If you want to make it easier, follow the below steps.

You can Integrate Azure ADB2C directly from VS while creating the Web App Template.

  • Select the Authentication as Microsoft Identity platform.

enter image description here

  • As soon as the Web App template is created, you will get an option to Install components related to msidentity.

enter image description here

  • Select the correct tenant related to ADB2C => click on Create new and continue with next steps.

enter image description here

  • This step will register a new app in App registrations section in ADB2C.

enter image description here

  • Here I have created an app with name ASPFramework, you can check the same in the ADB2C.

Visual Studio: enter image description here

In Portal: enter image description here

  • Continue with the next steps.
  • Below changes are made in the WebApp.

enter image description here

Dependency Configuration progress:

Retrieved B2C Sign-up/Sign-in Policy with id: B2C_1_SUSI
Connecting to Microsoft identity platform dependency identityapp1 in the project...
Updating remote app registration: dotnet msidentity --update-app-registration --username **********.com --tenant-id ******** --client-id ****** --enable-id-token --json --instance https://login.microsoftonline.com/ --redirect-uris https://localhost:44344/signin-oidc
Successfully updated app registration ASPFramework (********)
Adding settings to C:\Users\****\ADB2CASPFramework\ADB2CASPFramework\Web.config...
Complete. Microsoft identity platform identityapp1 is configured.
  • Check StartupAuth.cs under App_Start,Web.config,.csproj for the automatically Integrated code and packages.

Output:

enter image description here