Error Uri is null EditProfile B2C .Net

Santiago Esteawens Torres Zapata 26 Reputation points
2021-10-11T21:29:08.033+00:00

Hi,

I have a project MVC in .Net Core 5 this connect to Azure AD B2C, all it works, but in the Edit button sometimes returned following error:

Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler[12]
Message contains error: 'server_error', error_description: 'AADB2C: An exception has occurred.
Correlation ID: c64a6070-e437-4373-905c-e1db69035e56
Timestamp: 2021-10-11 21:05:48Z
', error_uri: 'error_uri is null'.

Below the configuration in Startup.cs file:

    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAdB2C"));

            services.AddControllersWithViews(options =>
            {
                var policy = new AuthorizationPolicyBuilder()
                    .RequireAuthenticatedUser()
                    .Build();
                options.Filters.Add(new AuthorizeFilter(policy));

                var user = new AuthorizationPolicyBuilder()
                    .RequireAuthenticatedUser()
                    .Build();
            });
            services.AddRazorPages()
                 .AddMicrosoftIdentityUI();

            services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
            {
                var previousOptions = options.Events.OnRedirectToIdentityProvider;
                options.Events.OnRedirectToIdentityProvider = async context =>
                {
                    await previousOptions(context);
                    context.ProtocolMessage.ResponseType = Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectResponseType.IdToken;
                };
            });

            services.Configure<ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
                options.KnownNetworks.Clear();
                options.KnownProxies.Clear();
            });            

            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
                options.Secure = CookieSecurePolicy.Always;
                options.HandleSameSiteCookieCompatibility();
            });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseForwardedHeaders();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
    }

Any idea for this error.

I really appreciate it.

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,631 questions
{count} votes

Accepted answer
  1. Siva-kumar-selvaraj 15,546 Reputation points
    2021-10-14T11:51:39.617+00:00

    Hello @Santiago Esteawens Torres Zapata ,

    Thanks for reaching out and apologies for any inconvenience caused by above issue.

    This seems to be related with glitch caused by backend issue and our engineering team have already developed a fix which should be rolled out to all Datacenters by end of this week.

    We have already verified fix with new tenant which is all working as expected without any issue.

    If you have any other questions, please let me know. Thank you for your time and patience throughout this issue.

    Hope this helps.

    ------
    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous 1 Reputation point
    2021-10-13T11:27:34.127+00:00

    I've been having the same issue, only started recently. hitting the standard passwordreset userflow.

    Error.
    An error occurred while processing your request.
    Request ID: |89b83d59-43878148111a70cb.

    Details
    Message contains error: 'server_error', error_description: 'AADB2C: An exception has occurred. Correlation ID: 041fa9ca-db65-4eaf-a266-cf3dc171ec55 Timestamp: 2021-10-13 11:26:29Z ', error_uri: 'error_uri is null'.

    0 comments No comments

  2. Anonymous 1 Reputation point
    2021-10-18T19:21:32.063+00:00

    Does anyone know if the fix has been applied ?

    Still getting errors.