-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
97 lines (82 loc) · 5.24 KB
/
Program.cs
File metadata and controls
97 lines (82 loc) · 5.24 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
87
88
89
90
91
92
93
94
95
96
97
/*==============================================================================================================================
| Author Ignia, LLC
| Client Ignia, LLC
| Project Sample OnTopic Site
\=============================================================================================================================*/
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.Extensions.FileProviders;
using OnTopic.AspNetCore.Mvc;
using OnTopic.Editor.AspNetCore;
using OnTopicTest;
#pragma warning disable CA1812 // Avoid uninstantiated internal classes
/*==============================================================================================================================
| CONFIGURE SERVICES
\-----------------------------------------------------------------------------------------------------------------------------*/
var builder = WebApplication.CreateBuilder(args);
/*------------------------------------------------------------------------------------------------------------------------------
| Configure: Cookie Policy
\-----------------------------------------------------------------------------------------------------------------------------*/
builder.Services.Configure<CookiePolicyOptions>(options => {
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
/*------------------------------------------------------------------------------------------------------------------------------
| Configure: MVC
\-----------------------------------------------------------------------------------------------------------------------------*/
var mvcBuilder = builder.Services.AddControllersWithViews()
//Add OnTopic support
.AddTopicSupport()
//Add OnTopic editor support
.AddTopicEditor();
/*------------------------------------------------------------------------------------------------------------------------------
| Configure: Runtime View Compilation
\-----------------------------------------------------------------------------------------------------------------------------*/
if (builder.Environment.IsDevelopment()) {
mvcBuilder.AddRazorRuntimeCompilation();
builder.Services.Configure<MvcRazorRuntimeCompilationOptions>(options => {
var libraryPath = Path.GetFullPath(Path.Combine(builder.Environment.ContentRootPath, "..", "OnTopic.Editor.AspNetCore"));
var pluginsPath = Path.GetFullPath(Path.Combine(builder.Environment.ContentRootPath, "..", "OnTopic.Editor.AspNetCore.Attributes"));
options.FileProviders.Add(new PhysicalFileProvider(libraryPath));
options.FileProviders.Add(new PhysicalFileProvider(pluginsPath));
});
}
/*------------------------------------------------------------------------------------------------------------------------------
| Register: Activators
\-----------------------------------------------------------------------------------------------------------------------------*/
var activator = new SampleActivator(builder.Configuration.GetConnectionString("OnTopic"), builder.Environment);
builder.Services.AddSingleton<IControllerActivator>(activator);
builder.Services.AddSingleton<IViewComponentActivator>(activator);
/*==============================================================================================================================
| CONFIGURE APPLICATION
\-----------------------------------------------------------------------------------------------------------------------------*/
var app = builder.Build();
/*------------------------------------------------------------------------------------------------------------------------------
| Configure: Error Pages
\-----------------------------------------------------------------------------------------------------------------------------*/
if (app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
else {
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
/*------------------------------------------------------------------------------------------------------------------------------
| Configure: Server defaults
\-----------------------------------------------------------------------------------------------------------------------------*/
//app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
/*------------------------------------------------------------------------------------------------------------------------------
| Configure: MVC
\-----------------------------------------------------------------------------------------------------------------------------*/
app.MapControllers();
app.MapTopicEditorRoute();
/*------------------------------------------------------------------------------------------------------------------------------
| Run application
\-----------------------------------------------------------------------------------------------------------------------------*/
app.Run();
#pragma warning restore CA1812 // Avoid uninstantiated internal classes