C#C
C#4mo ago
JayNic

Request Entity Too Large in Azure Web App Production Environment

I'm encountering an error when I'm using an OnPost handler in a razor page to upload files.
In debug: the files upload no problem, but as soon as I push to production and try on the actual site: it gives me this error.

I have put the following on my PageModel:
[RequestSizeLimit(100 * 1024 * 1024)]
[RequestFormLimits(MultipartBodyLengthLimit = 100 * 1024 * 1024)]
public class ImagesManagerModel : PageModelBase
{
...


I've also added the following in my program.cs:
builder.WebHost.ConfigureKestrel(opt =>
{
    opt.Limits.MaxRequestBodySize = 100 * 1024 * 1024;
});
builder.Services.Configure<FormOptions>(options =>
{
    options.MultipartBodyLengthLimit = 100 * 1024 * 1024;
});


and even this in my appsettings.json:
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "FormOptions": {
    "MultipartBodyLengthLimit": 100000000
  }
}


The app is hosted as an Azure App Service. Is there a portal side thing I need to change? Or am I going about this in the totally wrong way?

Thanks
Was this page helpful?