Notes/Program.cs

37 lines
851 B
C#
Raw Normal View History

2022-11-29 15:14:15 +00:00
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
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();
}
2022-12-01 02:43:22 +00:00
// create file
var configuration = app.Services.GetService<IConfiguration>();
var filePath = configuration["ContentFilePath"];
if (!File.Exists(filePath))
{
File.WriteAllText(filePath, string.Empty);
}
2022-11-29 15:14:15 +00:00
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();