79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Net.Http.Json;
|
||
|
using System.Threading.Tasks;
|
||
|
using Microsoft.AspNetCore.Builder;
|
||
|
using Microsoft.AspNetCore.Hosting;
|
||
|
using Microsoft.AspNetCore.HttpsPolicy;
|
||
|
using Microsoft.AspNetCore.Identity;
|
||
|
using Microsoft.AspNetCore.Identity.UI;
|
||
|
using Microsoft.EntityFrameworkCore;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Microsoft.Extensions.Hosting;
|
||
|
using Props.Data;
|
||
|
using Props.Models;
|
||
|
using Props.Services;
|
||
|
|
||
|
namespace Props
|
||
|
{
|
||
|
public class Startup
|
||
|
{
|
||
|
public Startup(IConfiguration configuration, IWebHostEnvironment webHostEnvironment)
|
||
|
{
|
||
|
Configuration = configuration;
|
||
|
environment = webHostEnvironment;
|
||
|
}
|
||
|
|
||
|
public IConfiguration Configuration { get; }
|
||
|
private readonly IWebHostEnvironment environment;
|
||
|
|
||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||
|
public void ConfigureServices(IServiceCollection services)
|
||
|
{
|
||
|
if (environment.IsDevelopment())
|
||
|
{
|
||
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||
|
options.UseSqlite(
|
||
|
Configuration.GetConnectionString("DefaultConnection")));
|
||
|
services.AddDatabaseDeveloperPageExceptionFilter();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||
|
options.UseSqlServer(
|
||
|
Configuration.GetConnectionString("DefaultConnection")));
|
||
|
}
|
||
|
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||
|
services.AddRazorPages();
|
||
|
|
||
|
services.AddSingleton(typeof(IContentManager<>), typeof(JsonContentManager<>));
|
||
|
}
|
||
|
|
||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||
|
public void Configure(IApplicationBuilder app)
|
||
|
{
|
||
|
if (environment.IsDevelopment())
|
||
|
{
|
||
|
app.UseDeveloperExceptionPage();
|
||
|
}
|
||
|
app.UseMigrationsEndPoint();
|
||
|
|
||
|
app.UseHttpsRedirection();
|
||
|
app.UseStaticFiles();
|
||
|
|
||
|
app.UseRouting();
|
||
|
|
||
|
app.UseAuthentication();
|
||
|
app.UseAuthorization();
|
||
|
|
||
|
app.UseEndpoints(endpoints =>
|
||
|
{
|
||
|
endpoints.MapRazorPages();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|