using Hcs.WebApp.Components; using Hcs.WebApp.Data; using Hcs.WebApp.Services; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Radzen; var builder = WebApplication.CreateBuilder(args); builder.Services .AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddControllers(); builder.Services.AddRadzenComponents(); builder.Services.AddHttpClient("WithIdentity").AddHeaderPropagation(x => x.Headers.Add("Cookie")); builder.Services.AddHeaderPropagation(x => x.Headers.Add("Cookie")); builder.Services.AddAuthentication(); builder.Services.AddAuthorization(); builder.Services.AddScoped(); var connectionString = builder.Configuration.GetConnectionString("IdentityConnection") ?? throw new InvalidOperationException("Не удалось получить значение из 'IdentityConnection'"); builder.Services.AddDbContext(options => options.UseSqlServer(connectionString)); builder.Services .AddIdentity(options => { options.Password.RequiredLength = 6; options.Password.RequireNonAlphanumeric = false; options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireUppercase = false; options.Password.RequiredUniqueChars = 1; }) .AddEntityFrameworkStores() .AddDefaultTokenProviders(); #if USE_MOCK builder.Services.AddTransient(); #else builder.Services.AddTransient(); #endif var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/error", createScopeForErrors: true); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseHeaderPropagation(); app.UseRouting(); app.UseAntiforgery(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); app .MapRazorComponents() .AddInteractiveServerRenderMode(); app.Run();