62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using LANCommander.Data;
|
|
using LANCommander.Data.Models;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
|
|
|
builder.Services.AddDbContext<LANCommander.Data.DatabaseContext>(b =>
|
|
{
|
|
b.UseLazyLoadingProxies();
|
|
b.UseSqlite(connectionString);
|
|
});
|
|
|
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
|
|
|
builder.Services.AddDefaultIdentity<User>((IdentityOptions options) => {
|
|
options.SignIn.RequireConfirmedAccount = false;
|
|
options.Password.RequireNonAlphanumeric = false;
|
|
options.SignIn.RequireConfirmedEmail = false;
|
|
})
|
|
.AddRoles<Role>()
|
|
.AddEntityFrameworkStores<LANCommander.Data.DatabaseContext>();
|
|
|
|
builder.Services.AddControllersWithViews();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseMigrationsEndPoint();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
app.MapRazorPages();
|
|
|
|
if (!Directory.Exists("Upload"))
|
|
Directory.CreateDirectory("Upload");
|
|
|
|
app.Run(); |