Files
abzarasadi/Program.cs
T
Soroush Asadi f97f891d67
CI/CD / CI — dotnet build (push) Successful in 44s
CI/CD / Deploy — docker compose (push) Failing after 1s
Initial commit — AsadiTools v1.0
Full ASP.NET Core 10 Razor Pages app for آساد ابزار tool repair shop
in Karaj, Iran (official DeWalt representative).

Features:
- Homepage, Services, DeWalt page, Shop (pagination + images)
- 10 brand SEO pages (/brands/*) with rich Persian content + FAQ schema
- Blog engine with admin management (/blog, /Admin/Blog)
- Cart, Checkout, Contact (OpenStreetMap embed)
- Admin panel: Products CRUD, Orders, Blog, Change Password
- Jalali date formatting, product images, SiteData centralised contact
- Docker + docker-compose with healthcheck
- Gitea CI/CD via .gitea/workflows/ci-cd.yml (NuGet through Nexus mirror)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 22:08:43 +03:30

61 lines
1.6 KiB
C#

using AsadiTools.Data;
using AsadiTools.Services;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
// Persist DataProtection keys to the volume so sessions/antiforgery survive restarts
var dpKeysPath = builder.Configuration["DataProtection:KeysPath"] ?? "/app/data/keys";
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(dpKeysPath))
.SetApplicationName("AsadiTools");
builder.Services.AddRazorPages();
builder.Services.AddSession(o =>
{
o.IdleTimeout = TimeSpan.FromHours(2);
o.Cookie.HttpOnly = true;
o.Cookie.IsEssential = true;
});
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<CartService>();
builder.Services.AddDbContext<AppDbContext>(o =>
o.UseSqlite(builder.Configuration.GetConnectionString("Default")
?? "Data Source=asadi.db"));
builder.Services.AddAuthentication("AdminCookie")
.AddCookie("AdminCookie", o =>
{
o.LoginPath = "/Admin/Login";
o.LogoutPath = "/Admin/Logout";
o.Cookie.Name = "AsadiAdmin";
o.ExpireTimeSpan = TimeSpan.FromHours(8);
});
builder.Services.AddAuthorization();
var app = builder.Build();
using (var scope = app.Services.CreateScope())
SeedData.Initialize(scope.ServiceProvider.GetRequiredService<AppDbContext>());
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseSession();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapStaticAssets();
app.MapRazorPages().WithStaticAssets();
app.Run();