Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

blazor scheme already exists : addidentities

$
0
0

As you can see in the screenshot, I have only one place where i add identity. I made a custom user manager and registered it.

I don't know how to get any other possible duplicate, and it says it's already added

enter image description here

using Microsoft.AspNetCore.Components.Authorization;using Microsoft.AspNetCore.Identity;using Microsoft.EntityFrameworkCore;using Swamp.Components;using Swamp.Components.Account;using Swamp.Data;var builder = WebApplication.CreateBuilder(args);// Add services to the container.builder.Services.AddRazorComponents()    .AddInteractiveServerComponents();builder.Services.AddCascadingAuthenticationState();builder.Services.AddScoped<IdentityUserAccessor>();builder.Services.AddScoped<IdentityRedirectManager>();builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");builder.Services.AddDbContextFactory<ApplicationDbContext>(options =>    options.UseSqlServer(connectionString));builder.Services.AddQuickGridEntityFrameworkAdapter(); ;builder.Services.AddAuthentication(options =>    {        options.DefaultScheme = IdentityConstants.ApplicationScheme;        options.DefaultSignInScheme = IdentityConstants.ExternalScheme;    })    .AddIdentityCookies();builder.Services.AddDbContext<ApplicationDbContext>(options =>    options.UseSqlServer(connectionString));builder.Services.AddQuickGridEntityFrameworkAdapter();builder.Services.AddDatabaseDeveloperPageExceptionFilter();builder.Services.AddIdentity<ApplicationUser, IdentityRole>()    .AddUserManager<UserManagerExtension>()    .AddEntityFrameworkStores<ApplicationDbContext>()    .AddSignInManager()    .AddDefaultTokenProviders();builder.Services.AddServerSideBlazor().AddCircuitOptions(x => x.DetailedErrors = true);builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>();var app = builder.Build();// Configure the HTTP request pipeline.if (app.Environment.IsDevelopment()){    app.UseMigrationsEndPoint();}else{    app.UseExceptionHandler("/Error", createScopeForErrors: true);    // 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.UseMigrationsEndPoint();}app.UseHttpsRedirection();app.UseStaticFiles();app.UseAntiforgery();app.MapRazorComponents<App>()    .AddInteractiveServerRenderMode();// Add additional endpoints required by the Identity /Account Razor components.app.MapAdditionalIdentityEndpoints();app.Run();

I searched for any other place with Services.AddIdentities, nothing comes up


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>