using Hcs.WebApp.Components; using Hcs.WebApp.Data; using Hcs.WebApp.Identity; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Radzen; var builder = WebApplication.CreateBuilder(args); builder.Services .AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddRadzenComponents(); builder.Services.AddCascadingAuthenticationState(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services .AddAuthentication(options => { options.DefaultScheme = IdentityConstants.ApplicationScheme; options.DefaultSignInScheme = IdentityConstants.ExternalScheme; }) .AddIdentityCookies(); var connectionString = builder.Configuration.GetConnectionString("IdentityConnection") ?? throw new InvalidOperationException("Не удалось получить значение из 'IdentityConnection'"); builder.Services.AddDbContext(options => options.UseSqlServer(connectionString)); builder.Services.AddDatabaseDeveloperPageExceptionFilter(); builder.Services .AddIdentityCore() .AddEntityFrameworkStores() .AddSignInManager() .AddDefaultTokenProviders(); var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/error", createScopeForErrors: true); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app .MapRazorComponents() .AddInteractiveServerRenderMode(); app.MapAdditionalIdentityEndpoints(); app.Run();