Azure B2C Authentication

Hey Guys, I'm from a VB.net C# background an new new to ASP / Blazor development, but so far so good. I using Radzen for mainly the UI as I'm sure many do as it makes light work of it.

I'm attempting to make an app for our customers and I've decided to use Azure AD B2C. I created a demo Blazor project in VS 2019 to see how easy it was, it was fairly straight forward and worked no problems.

In a Radzen project we need to extend the partial Startup class as we need to add to it. So according to the docs;

public partial class Startup
{

    partial void OnConfigureServices(IServiceCollection services)
    {
        services.AddAuthentication(AzureADB2CDefaults.AuthenticationScheme)
            .AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
    }

    partial void OnConfigure(IApplicationBuilder app, IWebHostEnvironment envp)
    {
        app.UseAuthentication();
        app.UseAuthorization();
    }
}

However this causes the app to fail when getting the callback from Azure with an Error 400.

So for the sake of testing, I edited the Startup.cs file:

...
app.UseRouting();

app.UseAuthentication(); <------ Added these 2 lines here
app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    endpoints.MapBlazorHub();
    endpoints.MapFallbackToPage("/_Host");
});

OnConfigure(app, env);

and this works fine without the error on callback, but it gets lost upon changes in Radzen editor.

So any ideas on how to address this properly ?

Hi @henda,

Use Radzen's code generation ignore list.

Hey thanks for the quick reply. I was looking at that but was thinking there might be another way.

Why does it matter about the order ?

Not sure about that. Probably something related to the Microsoft implementation.

Thanks for the help, great product by the way !