-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
78 lines (62 loc) · 2.09 KB
/
Program.cs
File metadata and controls
78 lines (62 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Microsoft.EntityFrameworkCore;
using Forum.Models;
using Microsoft.AspNetCore.Identity;
using Forum.Hubs;
var builder = WebApplication.CreateBuilder(args);
//builder.WebHost.ConfigureKestrel(serverOptions =>
//{
// serverOptions.ListenAnyIP(5000); // Port HTTP
//});
// Configuration de la base de données MySQL
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseMySql(
builder.Configuration.GetConnectionString("DefaultConnection"),
ServerVersion.Parse("8.0.32-mysql")
));
// Ajouter les services au conteneur
builder.Services.AddControllersWithViews();
builder.Services.AddSignalR();
builder.Services.AddSingleton<PasswordHasher<Utilisateurs>>();
builder.Services.AddSingleton<PasswordHasher<Promos>>();
builder.Services.AddAuthentication();
builder.Services.AddAuthorization();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddSession(options =>
{
//options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
options.IdleTimeout = TimeSpan.FromHours(1);
options.Cookie.MaxAge = TimeSpan.FromHours(1);
});
//
var app = builder.Build();
// Configurer le pipeline de traitement des requêtes .
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSession();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseDeveloperExceptionPage();
//services.AddIdentity<ApplicationUser, IdentityRole>()
// .AddEntityFrameworkStores<ApplicationDbContext>()
// .AddDefaultTokenProviders();
app.MapHub<ChatHub>("/chatHub");
app.Use(async (context, next) =>
{
context.Response.Headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0";
context.Response.Headers["Pragma"] = "no-cache";
context.Response.Headers["Expires"] = "0";
await next();
});
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
//app.Run("http://0.0.0.0:5000");