29af996544
- Added Microsoft.Extensions.Hosting.WindowsServices package - Added builder.Host.UseWindowsService() to Program.cs - Service can now run either as console app or Windows Service
32 lines
922 B
C#
32 lines
922 B
C#
using ExcelToPdfService.Services;
|
|
using Syncfusion.Licensing;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host.UseWindowsService(); // Run as Windows Service (also works as console app)
|
|
|
|
// Syncfusion license
|
|
SyncfusionLicenseProvider.RegisterLicense(
|
|
builder.Configuration["Syncfusion:LicenseKey"]
|
|
?? "MjExMDkzMEAzMjMxMmUzMTJlMzMzNWd1RGM1NVFmUUMzWmZlN0dCc3NadUJyM1RUYVh1SHVSS1B2Tzdwa0NhcE09");
|
|
|
|
// Services
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddScoped<IExcelToPdfService, ExcelToPdfService.Services.ExcelToPdfService>();
|
|
|
|
// Allow large file uploads (50 MB)
|
|
builder.Services.Configure<Microsoft.AspNetCore.Http.Features.FormOptions>(o =>
|
|
{
|
|
o.MultipartBodyLengthLimit = 50 * 1024 * 1024;
|
|
});
|
|
builder.WebHost.ConfigureKestrel(o =>
|
|
{
|
|
o.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
app.UseHttpsRedirection();
|
|
app.MapControllers();
|
|
|
|
app.Run();
|