45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using WebClaimsPrincipal.Data;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
|
?? throw new InvalidOperationException("'DefaultConnection' not found.");
|
|
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
|
options.UseSqlServer(connectionString));
|
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
|
|
|
builder.Services.AddDefaultIdentity<IdentityUser>(options =>
|
|
options.SignIn.RequireConfirmedAccount = true)
|
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
|
|
|
// Force Identity's security stamp to be validated every minute.
|
|
builder.Services.Configure<SecurityStampValidatorOptions>(o =>
|
|
o.ValidationInterval = TimeSpan.FromMinutes(1));
|
|
|
|
builder.Services.AddRazorPages();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseMigrationsEndPoint();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapRazorPages();
|
|
|
|
app.Run();
|