question

moondaddy-8531 avatar image
0 Votes"
moondaddy-8531 asked YijingSun-MSFT commented

c# Asp Web API: HttpException: Maximum request length exceeded.

This might be a common question, but my situation is not so common.

I an sending a serialized image into an Asp.net Web API method and am getting this error:

System.Web.HttpException: Maximum request length exceeded.

at System.Web.HttpBufferlessInputStream.ValidateRequestEntityLength()


I searched online and found a lot of answers saying to do this in the web.config:


<system.web>
<httpRuntime maxRequestLength="40960" /> // 40MB (default)
</system.web>

<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" /> // 2GB
</requestFiltering>
</security>
</system.webServer>

but when I do that all of my other API calls fail. I get:

500 - Internal server error.

and no code executes in the API calls. they all fail.

So I cannot use this setting to allow bigger files to be send into the API.

What should I do?

thanks.








dotnet-csharpdotnet-aspnet-webapi
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @moondaddy-8531 ,
There are too many possiblies to cause the 500 errors. I suggest you could check your status codes in your log. And I found a possible that you could check your web.config if you have add multiple times of httpRuntime .
Best regards,
Yijing Sun

0 Votes 0 ·

0 Answers