main
Last change
on this file since 784b3ad was 2aea0fd, checked in by ElenaMoskova <elena.moskova99@…>, 4 months ago |
init commit Elena
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2aea0fd] | 1 | using Microsoft.AspNetCore.Identity;
|
---|
| 2 | using Microsoft.EntityFrameworkCore;
|
---|
| 3 | using PostgreSqlDotnetCore.Data;
|
---|
| 4 |
|
---|
| 5 | var builder = WebApplication.CreateBuilder(args);
|
---|
| 6 |
|
---|
| 7 | // Add services to the container.
|
---|
| 8 | var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
---|
| 9 | builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
---|
| 10 | options.UseNpgsql(connectionString));
|
---|
| 11 | builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
---|
| 12 |
|
---|
| 13 | builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
---|
| 14 | .AddEntityFrameworkStores<ApplicationDbContext>();
|
---|
| 15 | builder.Services.AddControllersWithViews();
|
---|
| 16 |
|
---|
| 17 | var app = builder.Build();
|
---|
| 18 |
|
---|
| 19 | // Configure the HTTP request pipeline.
|
---|
| 20 | if (app.Environment.IsDevelopment())
|
---|
| 21 | {
|
---|
| 22 | app.UseMigrationsEndPoint();
|
---|
| 23 | }
|
---|
| 24 | else
|
---|
| 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 |
|
---|
| 31 | app.UseHttpsRedirection();
|
---|
| 32 | app.UseStaticFiles();
|
---|
| 33 |
|
---|
| 34 | app.UseRouting();
|
---|
| 35 |
|
---|
| 36 | app.UseAuthorization();
|
---|
| 37 |
|
---|
| 38 | app.MapControllerRoute(
|
---|
| 39 | name: "default",
|
---|
| 40 | pattern: "{controller=Home}/{action=Index}/{id?}");
|
---|
| 41 | app.MapRazorPages();
|
---|
| 42 |
|
---|
| 43 | app.Run();
|
---|
Note:
See
TracBrowser
for help on using the repository browser.