We recently came across an issue where a specific front end feature was blocking file uploads, where the file was greater than 30MB (Angular front end, and .Net 8 API).
In the past we had the web.config
, but the current approach is appsettings.json
.
In the older web.config, we had the following requestLimits
property:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
which can NO LONGER be added to appsettings.json in .Net 8 projects.
So, the question is: how can we build this requestFiltering
section into the web.config at Publish time.
Here is an example of FolderProfile.pubxml in our project:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net8.0-windows8.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>
Is this something that can be somehow injected into the web.config at build time or publish time ?
Try placing the web.config with only the needed lines in your project.