-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
48 lines (36 loc) · 1.19 KB
/
Program.cs
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
using Microsoft.EntityFrameworkCore;
using URL_Shortener.Middleware;
using URL_Shortener.Models;
using URL_Shortener.Models.Interactives;
using URL_Shortener.Services;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<IHostedService, DailyTaskService>();
builder.Services.AddScoped<IUrlInteractive, UrlInteractive>();
builder.Services.AddScoped<IUserInteractive, UserInteractive>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IUrlService, UrlService>();
builder.Services.AddSession();
builder.Services.AddHttpContextAccessor();
builder.Services.AddRazorPages(options =>
{
options.Conventions.AddPageRoute("/index", "{*url}");
});
builder.Services.AddDbContext<UrlShortenerDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("UrlShortenerDbContextConnection"));
options.EnableSensitiveDataLogging();
}
);
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseSession();
app.UseRouting();
app.UseAuthentication();
//app.UseUserMiddleware();
app.UseMiddleware<UserMiddleware>();
app.MapRazorPages();
app.Run();