1 | using Microsoft.AspNetCore.Builder;
|
---|
2 | using Microsoft.AspNetCore.Hosting;
|
---|
3 | using Microsoft.AspNetCore.HttpsPolicy;
|
---|
4 | using Microsoft.Extensions.Configuration;
|
---|
5 | using Microsoft.Extensions.DependencyInjection;
|
---|
6 | using Microsoft.Extensions.Hosting;
|
---|
7 | using System;
|
---|
8 | using System.Collections.Generic;
|
---|
9 | using System.Linq;
|
---|
10 | using System.Threading.Tasks;
|
---|
11 | using db_tsh.Models;
|
---|
12 | using Microsoft.EntityFrameworkCore;
|
---|
13 | using Microsoft.AspNetCore.Authentication.Cookies;
|
---|
14 |
|
---|
15 | namespace db_tsh
|
---|
16 | {
|
---|
17 | public class Startup
|
---|
18 | {
|
---|
19 | public Startup(IConfiguration configuration)
|
---|
20 | {
|
---|
21 | Configuration = configuration;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public IConfiguration Configuration { get; }
|
---|
25 |
|
---|
26 | // This method gets called by the runtime. Use this method to add services to the container.
|
---|
27 | public void ConfigureServices(IServiceCollection services)
|
---|
28 | {
|
---|
29 |
|
---|
30 | services.AddControllersWithViews();
|
---|
31 | services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
---|
32 | .AddCookie(options => {
|
---|
33 | options.LoginPath = "/Account/RegisterOrLogin";
|
---|
34 | options.LogoutPath = "/Account/Logout";
|
---|
35 | });
|
---|
36 | }
|
---|
37 |
|
---|
38 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
---|
39 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
---|
40 | {
|
---|
41 | if (env.IsDevelopment())
|
---|
42 | {
|
---|
43 | app.UseDeveloperExceptionPage();
|
---|
44 | }
|
---|
45 | else
|
---|
46 | {
|
---|
47 | app.UseExceptionHandler("/Home/Error");
|
---|
48 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
---|
49 | app.UseHsts();
|
---|
50 | }
|
---|
51 | app.UseHttpsRedirection();
|
---|
52 | app.UseStaticFiles();
|
---|
53 | app.UseAuthentication();
|
---|
54 | app.UseRouting();
|
---|
55 |
|
---|
56 | app.UseAuthorization();
|
---|
57 |
|
---|
58 | app.UseEndpoints(endpoints =>
|
---|
59 | {
|
---|
60 | endpoints.MapControllerRoute(
|
---|
61 | name: "default",
|
---|
62 | pattern: "{controller=Account}/{action=RegisterOrLogin}/{id?}");
|
---|
63 | });
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|