-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
86 lines (71 loc) · 2.8 KB
/
Program.cs
File metadata and controls
86 lines (71 loc) · 2.8 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
79
80
81
82
83
84
85
86
using System.Data.Entity.Core.Mapping;
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Infrastructure.MappingViews;
using IDMSWebServer.Models.DataModels;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.EntityFrameworkCore;
//EF CORE 模型預熱
//Console.WriteLine("模型預熱");
//using (var context = new IDMSContext())
//{
// var objectContent = ((IObjectContextAdapter)context).ObjectContext;
// var mappingCollection = (StorageMappingItemCollection)objectContent.MetadataWorkspace.GetItemCollection(System.Data.Entity.Core.Metadata.Edm.DataSpace.CSpace);
// mappingCollection.GenerateViews(new List<EdmSchemaError>());
//}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddDirectoryBrowser();
builder.Services.Configure<JsonOptions>(options =>
{
options.SerializerOptions.PropertyNamingPolicy = null;
options.SerializerOptions.PropertyNameCaseInsensitive = false;
options.SerializerOptions.WriteIndented = true;
});
builder.Services.Configure<BrotliCompressionProviderOptions>(option => option.Level = System.IO.Compression.CompressionLevel.Optimal);
builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
{
"text/html;charset=uft-8",
"application/json;charset=utf-8"
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
// app.UseSwagger();
// app.UseSwaggerUI();
//}
app.UseSwagger();
app.UseSwaggerUI();
app.UseWebSockets();
app.UseCors(c => c.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());
//app.UseDefaultFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseVueRouterHistory();
//IConfiguration configuration = app.Configuration;
//var _ic = configuration.GetSection("IDMS");
//var SystemLogDirectory = _ic.GetValue("SystemLogDirectory", "");
//var _fileProvider = new PhysicalFileProvider($@"{SystemLogDirectory}");
//var _requestPath = "/Data";
//app.UseFileServer(new FileServerOptions()
//{
// FileProvider = _fileProvider,
// RequestPath = _requestPath,
// EnableDirectoryBrowsing = true,
//});
//app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.UseResponseCompression();
Console.WriteLine(Environment.CurrentDirectory);
app.Run();