-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
80 lines (56 loc) · 1.74 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
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
79
80
using Elanat;
using Microsoft.AspNetCore.StaticFiles;
using SetCodeBehind;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDistributedMemoryCache();
builder.Services.AddResponseCaching();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromSeconds(StaticLoad.GetSessionLifeTime().ToNumber());
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
builder.Services.AddMemoryCache();
var app = builder.Build();
app.UseSession();
app.UseHttpsRedirection();
app.UseRouting();
app.UseResponseCaching();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/page/error/");
app.UseHsts();
}
CodeBehindCompiler.Initialization(true);
StaticObject.SystemStart();
StaticObject.ApplicationStart();
StaticObject.RunStartUp();
app.UseMiddleware<HandheldStaticFiles>();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".dat"] = "application/octet-stream";
provider.Mappings[".bak"] = "application/octet-stream";
app.UseStaticFiles(new StaticFileOptions()
{
ContentTypeProvider = provider
});
app.Use(async (context, next) =>
{
if (context.Session.GetString("el_session_set") == null)
{
StaticObject.SessionStart();
context.Session.SetString("el_session_set", "true");
}
await next(context);
});
app.Run(async context =>
{
// Is Repeated
if (context.Request.ContentType == null)
context.Request.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
PathAccessHandler pah = new PathAccessHandler();
pah.ProcessRequest(context);
await context.Response.WriteAsync(pah.ContentValue);
await context.Response.CompleteAsync();
});
app.Run();