-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
55 lines (45 loc) · 1.66 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
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Http;
using System.Net;
namespace AccountSystem;
public class Program {
public static async Task Main( string[] arguments ) {
WebApplicationBuilder builder = WebApplication.CreateBuilder( arguments );
builder.Logging.ClearProviders();
builder.Logging.AddSimpleConsole( options => {
options.IncludeScopes = false;
options.SingleLine = true;
options.TimestampFormat = "[HH:mm:ss] ";
} );
builder.Services.AddRazorPages(); // Add services to the container
WebApplication app = builder.Build();
// Configure the HTTP request pipeline
if ( !app.Environment.IsDevelopment() ) {
app.UseExceptionHandler( "/Error ");
//app.UseHsts(); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
}
//app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseStatusCodePages();
app.MapRazorPages();
app.MapControllerRoute( name: "default", pattern: "api/{controller=Home}/{action=Index}/{id?}" );
app.UseStatusCodePages( async ( context ) => {
HttpRequest request = context.HttpContext.Request;
HttpResponse response = context.HttpContext.Response;
if ( request.Path.StartsWithSegments( "/api" ) ) {
response.ContentType = "application/json";
await response.WriteAsync( "{}" );
}
} );
await app.RunAsync();
}
}