25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

53 satır
1.6KB

  1. using CartWise.Application;
  2. using CartWise.Infrastructure;
  3. using CartWise.Infrastructure.Data;
  4. using CartWise.Web.Authorization;
  5. using Microsoft.AspNetCore.Authorization;
  6. using Microsoft.EntityFrameworkCore;
  7. var builder = WebApplication.CreateBuilder(args);
  8. // Add services to the container.
  9. builder.Services.AddControllersWithViews();
  10. builder.Services.AddApplication();
  11. builder.Services.AddInfrastructure(builder.Configuration);
  12. builder.Services.AddScoped<IAuthorizationHandler, HouseholdMemberAuthorizationHandler>();
  13. builder.Services.AddAuthorizationBuilder()
  14. .AddPolicy("HouseholdMember", policy => policy.Requirements.Add(new HouseholdMemberRequirement()));
  15. var app = builder.Build();
  16. // Configure the HTTP request pipeline.
  17. if (!app.Environment.IsDevelopment())
  18. {
  19. app.UseExceptionHandler("/Home/Error");
  20. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  21. app.UseHsts();
  22. }
  23. else
  24. {
  25. // Local-first MVP: keep the SQLite schema current without a manual migration step.
  26. using var scope = app.Services.CreateScope();
  27. scope.ServiceProvider.GetRequiredService<CartWiseDbContext>().Database.Migrate();
  28. }
  29. app.UseHttpsRedirection();
  30. app.UseRouting();
  31. app.UseAuthentication();
  32. app.UseAuthorization();
  33. app.MapStaticAssets();
  34. app.MapControllerRoute(
  35. name: "default",
  36. pattern: "{controller=Home}/{action=Index}/{id?}")
  37. .WithStaticAssets();
  38. app.Run();
  39. // Exposed so Microsoft.AspNetCore.Mvc.Testing (WebApplicationFactory<Program>) can bootstrap the app in tests.
  40. public partial class Program;

Powered by TurnKey Linux.