Updated the `Program.cs` file to enhance static file handling: - Corrected the comment for `.mjs` MIME type registration. - Added a new MIME type mapping for `.ftl` files as `text/plain`. - Updated `UseStaticFiles` middleware to use a `StaticFileOptions` object with the modified `ContentTypeProvider`. These changes ensure proper serving of `.mjs` and `.ftl` files with appropriate content type headers.
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using DXApp.TemplateKitProject.Data;
|
|
using DXApp.TemplateKitProject.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddRazorPages();
|
|
|
|
// Datenbank
|
|
var connectionString = builder.Configuration.GetConnectionString("EcmContext")
|
|
?? throw new InvalidOperationException("Connection string 'EcmContext' not found.");
|
|
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
options.UseSqlServer(connectionString));
|
|
|
|
// Services
|
|
builder.Services.AddScoped<PdfAttachmentExtractorService>();
|
|
builder.Services.AddScoped<PdfResultPackageService>();
|
|
builder.Services.AddScoped<ZugferdExtractorService>();
|
|
builder.Services.AddScoped<ZugferdParserService>();
|
|
builder.Services.AddScoped<ZugferdImportService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
// MIME-Types für PDF.js registrieren (einmaliger UseStaticFiles-Aufruf)
|
|
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
|
|
provider.Mappings[".mjs"] = "text/javascript";
|
|
provider.Mappings[".ftl"] = "text/plain";
|
|
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
|
|
|
|
app.UseRouting();
|
|
app.UseAuthorization();
|
|
app.MapRazorPages();
|
|
app.Run(); |