CodexBloom - Programming Q&A Platform

best practices for 'Exceeded maximum request size' scenarios when using Azure API Management with .NET 6 backend?

👀 Views: 41 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-10
azure api-management .net-6 C#

I'm writing unit tests and I'm sure I'm missing something obvious here, but Quick question that's been bugging me - I'm working with an scenario where my Azure API Management (APIM) instance returns a `415 Unsupported Media Type` behavior with the message 'Exceeded maximum request size' when I try to send large payloads (over 2 MB) to my .NET 6 Web API backend. I have configured the backend to accept larger payloads, and I've also set the `maxRequestBodySize` in my `Startup.cs` configuration like this: ```csharp public void ConfigureServices(IServiceCollection services) { services.Configure<FormOptions>(options => { options.MultipartBodyLengthLimit = 10 * 1024 * 1024; // 10 MB }); } ``` Additionally, I've checked my APIM settings and ensured that the 'Request size limit' is set to a higher value (like 10 MB), but I'm still running into this scenario. I also included the necessary API version in the request header to ensure compatibility, but the behavior continues. I've tried removing any content negotiation headers and testing various payload sizes, and I've confirmed that the .NET API itself can handle large requests when called directly (not through APIM). I would appreciate any insights on how to effectively troubleshoot this question or any configuration changes I may have missed that would allow larger requests to be processed through Azure API Management without hitting this limit. I'm using C# latest in this project. Thanks for your help in advance! This is part of a larger REST API I'm building. Any feedback is welcome!