source: PostgreSqlDotnetCore/Program.cs@ 2aea0fd

main
Last change on this file since 2aea0fd was 2aea0fd, checked in by ElenaMoskova <elena.moskova99@…>, 2 months ago

init commit Elena

  • Property mode set to 100644
File size: 1.3 KB
Line 
1using Microsoft.AspNetCore.Identity;
2using Microsoft.EntityFrameworkCore;
3using PostgreSqlDotnetCore.Data;
4
5var builder = WebApplication.CreateBuilder(args);
6
7// Add services to the container.
8var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
9builder.Services.AddDbContext<ApplicationDbContext>(options =>
10 options.UseNpgsql(connectionString));
11builder.Services.AddDatabaseDeveloperPageExceptionFilter();
12
13builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
14 .AddEntityFrameworkStores<ApplicationDbContext>();
15builder.Services.AddControllersWithViews();
16
17var app = builder.Build();
18
19// Configure the HTTP request pipeline.
20if (app.Environment.IsDevelopment())
21{
22 app.UseMigrationsEndPoint();
23}
24else
25{
26 app.UseExceptionHandler("/Home/Error");
27 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
28 app.UseHsts();
29}
30
31app.UseHttpsRedirection();
32app.UseStaticFiles();
33
34app.UseRouting();
35
36app.UseAuthorization();
37
38app.MapControllerRoute(
39 name: "default",
40 pattern: "{controller=Home}/{action=Index}/{id?}");
41app.MapRazorPages();
42
43app.Run();
Note: See TracBrowser for help on using the repository browser.