When trying "Run user flow" in Azure ADB2C on Azure platform it throws: "OpenIdConnectAuthenticationHandler: message.State is null or empty"

AdamGie-4661 5 Reputation points
2024-01-30T12:37:19.83+00:00

I created .NET8 Web app using Azure ADB2c authorization based on this tutorial: Configure authentication in a sample web app by using Azure AD B2C

Log-in, log-out, showing claims works nicely both when I run it locally in Visual Studio as well as after deploying it on Azure Services. User's image

However, when in Azure portal I go to: "ADB2C -> User flows" and click on "Run user flow" and then select "Reply URL" corresponding to version deployed on Azure Service User's image

application displays an error: "OpenIdConnectAuthenticationHandler: message.State is null or empty." but it logs me in, as shown on below screen: User's image

Reply URL in ADB2C: https://adb2clogin23121979webapp.azurewebsites.net/signin-oidc App URL: https://adb2clogin23121979webapp.azurewebsites.net/ Configuration in my application: application.json

{
  "AzureAdB2C": {
    "Instance": "https://contosoorg23121979.b2clogin.com",
    "ClientId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "Domain": "xxxxx.onmicrosoft.com",
    "SignedOutCallbackPath": "/signout/B2C_1_SingInUp",
    "SignUpSignInPolicyId": "B2C_1_SingInUp",
    "ResetPasswordPolicyId": "B2C_1_ResetPassword",
    "EditProfilePolicyId": "B2C_1_ProfileEdit"
  }
}

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<CookiePolicyOptions>(options =>
    {
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
        options.HandleSameSiteCookieCompatibility();
    });

    services.AddMicrosoftIdentityWebAppAuthentication(Configuration, Constants.AzureAdB2C);

    services.AddControllersWithViews().AddMicrosoftIdentityUI();

    services.AddRazorPages();

    services.AddOptions();
    services.Configure<OpenIdConnectOptions>(Configuration.GetSection("AzureAdB2C"));
}
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,629 questions
{count} vote