CN.CAICT.IDIS.Client.Web/Program.cs

60 lines
1.5 KiB
C#

using BITKit;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using IDIS.Client.Web.Components;
using IDIS.Models;
using IDIS.Services;
using MudBlazor.Services;
await BITAppForNet.InitializeAsync("IDIS");
var config = Path.Combine(Environment.CurrentDirectory,"appsettings.json");
if (File.Exists(config))
{
var json = File.ReadAllText(config);
DataParser.Set(json);
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddMudServices();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddTransient<IDIS_Service, IDIS_Service_MySQLBased>();
builder.Services.AddTransient<IDIS_TemplateService, IDIS_TemplateService_MySQLBased>();
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
var app = builder.Build();
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
// Add additional endpoints required by the Identity /Account Razor components.
app.Run();