Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Infostacker.Services;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Serilog;
using Serilog.Core;
Expand Down Expand Up @@ -34,6 +35,12 @@
.AllowAnyMethod();
});
});

builder.Services.Configure<FormOptions>(options =>
{
options.MultipartBodyLengthLimit = 104857600; // 100MB
});

builder.Services.AddTransient<ISharingService, SharingService>();
builder.Services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Logging.ClearProviders();
Expand Down
2 changes: 2 additions & 0 deletions Services/SharingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public SharingService(ILogger<SharingService> logger, IConfiguration configurati
TemplateScriptPath = _configuration.GetSection("TemplateScriptPath").Value ?? string.Empty;
BuildVersion = _configuration.GetSection("version").Value ?? string.Empty;
MaxFileSize = int.Parse(_configuration.GetSection("MaxFileSizeInBytes").Value);


}

public async Task<Guid> UploadMarkdownWithFiles(string markdown, List<IFormFile> files)
Expand Down
2 changes: 1 addition & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"AdobeAPIToken": "",
"TemplatePath": "template.html",
"TemplateScriptPath": "templateScript.html",
"MaxFileSizeInBytes": 26214400,
"MaxFileSizeInBytes": 104857600,
"AllowedHosts": "*",
"SeqServer": ""
}
23 changes: 23 additions & 0 deletions iisexpress-web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Infostacker.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />

<!-- Request filtering for large file uploads -->
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600" />
</requestFiltering>
</security>
</system.webServer>
</location>

<!-- ASP.NET configuration for request limits -->
<system.web>
<httpRuntime maxRequestLength="102400" executionTimeout="300" />
</system.web>
</configuration>
75 changes: 50 additions & 25 deletions sample-web.config
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<location path="." inheritInChildApplications="false">
<system.webServer>
<!-- Remove conflicting modules -->
<modules>
<remove name="WebDAVModule" />
</modules>

<handlers>
<remove name="php-8.2.6" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\ShareAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
<!-- ASP.NET Core handler configuration -->
<handlers>
<remove name="php-8.2.6" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="Script" />
</handlers>

<!-- CORRECT: Use Infostacker.dll, not ShareAPI.dll -->
<aspNetCore processPath="dotnet"
arguments=".\Infostacker.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess" />

<cors enabled="true" failUnlistedOrigins="true">
<add origin="*">
<allowMethods>
<add method="GET" />
<add method="POST" />
<add method="PUT" />
<add method="DELETE" />
</allowMethods>
</add>
</cors>
</system.webServer>
</location>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
<!-- CORS configuration -->
<cors enabled="true" failUnlistedOrigins="true">
<add origin="*">
<allowMethods>
<add method="GET" />
<add method="POST" />
<add method="PUT" />
<add method="DELETE" />
</allowMethods>
</add>
</cors>

<!-- ADDED: Request filtering for file uploads -->
<security>
<requestFiltering>
<!-- Allow requests up to 100MB (52428800 bytes) -->
<requestLimits maxAllowedContentLength="104857600" />
</requestFiltering>
</security>

<!-- ADDED: Detailed error information -->
<httpErrors errorMode="Detailed" />
</system.webServer>
</location>

<!-- ADDED: ASP.NET configuration for request limits -->
<system.web>
<!-- Set maximum request length to 100MB (102400 KB) -->
<httpRuntime maxRequestLength="102400"
executionTimeout="300"
requestLengthDiskThreshold="102400" />
</system.web>
</configuration>