source: db_tsh/Startup.cs

main
Last change on this file was 705d6f5, checked in by ardit <ardit@…>, 2 days ago

Commiting all files of project - 20250224

  • Property mode set to 100644
File size: 2.1 KB
Line 
1using Microsoft.AspNetCore.Builder;
2using Microsoft.AspNetCore.Hosting;
3using Microsoft.AspNetCore.HttpsPolicy;
4using Microsoft.Extensions.Configuration;
5using Microsoft.Extensions.DependencyInjection;
6using Microsoft.Extensions.Hosting;
7using System;
8using System.Collections.Generic;
9using System.Linq;
10using System.Threading.Tasks;
11using db_tsh.Models;
12using Microsoft.EntityFrameworkCore;
13using Microsoft.AspNetCore.Authentication.Cookies;
14
15namespace 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}
Note: See TracBrowser for help on using the repository browser.