/
h0tnanny
/
DeliveryService
Обзор
Документация
Войти
/
h0tnanny
/
DeliveryService
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
DeliveryService.API/Program.cs
56 строк
2 KB
Хатнянский Максим
add razor pages
13 мар 2024, 20:33
13 мар 2024, 20:33
570f7a3
Код
Авторство
О чём код?
using DeliveryService.Persistence; using Microsoft.EntityFrameworkCore; namespace DeliveryService.API; public static class Program { public static async Task Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Logging.ClearProviders(); builder.Logging.AddConsole(); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddRazorPages(); builder.Services.AddDbContext<DeliveryDbContext>(options => { options.UseNpgsql(builder.Configuration.GetConnectionString("postgres")) .EnableSensitiveDataLogging() .EnableDetailedErrors() .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); }); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); using var scope = app.Services.CreateScope(); var context = scope.ServiceProvider.GetRequiredService<DeliveryDbContext>(); context.Database.EnsureCreated(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.UseStaticFiles(); app.MapControllers(); app.MapBlazorHub(); app.MapRazorPages(); await app.RunAsync(); } }