Entwicklung_BLAZOR/LambertzPortal/LambertzPortal/Program.cs
2026-03-13 11:17:08 +01:00

57 lines
1.4 KiB
C#

using LambertzPortal.Components;
using LambertzPortal.Data;
using LambertzPortal.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddDevExpressBlazor(options =>
{
options.SizeMode = DevExpress.Blazor.SizeMode.Medium;
});
builder.Services.AddMvc();
builder.Services.AddDbContext<LambertzDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("LambertzDb")));
builder.Services.AddAuthorization();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped<AuthService>();
builder.Services.AddHttpContextAccessor();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
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.UseAuthentication();
app.UseAuthorization();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AllowAnonymous();
app.Run();