usingKnzwTech.AspNetCore.ResourceBasedLocalization;usingMicrosoft.AspNetCore.Identity;// 追加usingMicrosoft.EntityFrameworkCore;usingT8b.Data;AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior",true);varbuilder=WebApplication.CreateBuilder(args);// Add services to the container.builder.Services.AddControllersWithViews(opt=>opt.EnableDefaultErrorMessagesFromResource());builder.Services.AddDbContext<T8bContext>(opt=>opt.UseNpgsql(builder.Configuration.GetConnectionString(nameof(T8bContext))));// Identity 用のデータコンテキストを追加する.builder.Services.AddDbContext<T8bIdentityContext>(opt=>opt.UseNpgsql(builder.Configuration.GetConnectionString(nameof(T8bIdentityContext))));// ASP.NET Core Identity のセットアップbuilder.Services.AddIdentity<IdentityUser,IdentityRole>().AddRoleManager<RoleManager<IdentityRole>>().AddDefaultTokenProviders().AddEntityFrameworkStores<T8bIdentityContext>();// 認証にCookieを使用するための設定builder.Services.ConfigureApplicationCookie(opt=>{opt.LoginPath="/Admin/Login";opt.LogoutPath="/Admin/Logout";opt.AccessDeniedPath="/Admin/AccessDenied";});varapp=builder.Build();// Configure the HTTP request pipeline.if(!app.Environment.IsDevelopment()){app.UseExceptionHandler("/Home/Error");}app.UseStaticFiles();app.UseStatusCodePagesWithReExecute("/Home/AccessError/{0}");app.UseRouting();app.UseAuthentication();// 認証を有効化するapp.UseAuthorization();app.MapControllerRoute(name:"default",pattern:"{controller=Home}/{action=Index}/{id?}");app.Run();