-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
56 lines (45 loc) · 1.26 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
using PAXSchedule;
using PAXSchedule.Services;
using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddRouting(options =>
{
options.LowercaseUrls = true;
options.LowercaseQueryStrings = true;
})
.AddMvc(options =>
options.OutputFormatters.Add(new CalendarOutputFormatter())
)
.AddJsonOptions(options => options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles);
builder.Services
.AddSingleton<GuidebookService>()
.AddHttpClient();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
// Redirect www.paxschedule.com to https://paxschedule.com
app.Use((context, next) =>
{
if (context.Request.Host.Host == "www.paxschedule.com")
{
context.Response.Redirect("https://paxschedule.com" + context.Request.Path, permanent: true);
return context.Response.StartAsync();
}
return next(context);
});
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapRazorPages();
app.Run();