You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting in ASP.NET Core 2.0.0, both Kestrel and HttpSys will be enforcing a a 30MB (~28.6 MiB) max request body size limit.
If the request body size exceeds the configured max request body size limit, the call to Request.Body.ReadAsync will throw an IOException. If this exception is uncaught, Kestrel will respond with a 413 Payload Too Large response and HttpSys will respond with a generic 500 Internal Server Error response.
This limit can be changed either globally or on a per-request basis, and is disabled for Kestrel running behind IIS where the normal web.config limit still applies.
MVC Instructions
If you want to change the max request body size limit for a specific MVC action or controller, you can use the RequestSizeLimit attribute. The following would allow MyAction to accept request bodies up to 100,000,000 bytes.
[DisableRequestSizeLimit] can be used to make request size unlimited. This effectively restores pre-2.0.0 behavior for just the attributed action or controller.
Generic Middleware Instructions
If the request is not being handled by an MVC action, the limit can still be modified on a per request basis using the IHttpMaxRequestBodySizeFeature. For example:
MaxRequestBodySize is a nullable long. Setting it to null disables the limit like MVC's [DisableRequestSizeLimit].
You can only configure the limit on a request if the application hasn’t started reading yet; otherwise an exception is thrown. There’s an IsReadOnly property that tells you if the MaxRequestBodySize property is in read-only state, meaning it’s too late to configure the limit.
Global Config Instructions
If you want to modify the max request body size globally, this can be done by modifying a MaxRequestBodySize property in the callback of either UseKestrel or UseHttpSys. MaxRequestBodySize is a nullable long in both cases. Ex:
Uh oh!
There was an error while loading. Please reload this page.
Starting in ASP.NET Core 2.0.0, both Kestrel and HttpSys will be enforcing a a 30MB (~28.6 MiB) max request body size limit.
If the request body size exceeds the configured max request body size limit, the call to
Request.Body.ReadAsync
will throw anIOException
. If this exception is uncaught, Kestrel will respond with a413 Payload Too Large
response and HttpSys will respond with a generic500 Internal Server Error
response.This limit can be changed either globally or on a per-request basis, and is disabled for Kestrel running behind IIS where the normal web.config limit still applies.
MVC Instructions
If you want to change the max request body size limit for a specific MVC action or controller, you can use the
RequestSizeLimit
attribute. The following would allowMyAction
to accept request bodies up to 100,000,000 bytes.[DisableRequestSizeLimit]
can be used to make request size unlimited. This effectively restores pre-2.0.0 behavior for just the attributed action or controller.Generic Middleware Instructions
If the request is not being handled by an MVC action, the limit can still be modified on a per request basis using the
IHttpMaxRequestBodySizeFeature
. For example:MaxRequestBodySize
is a nullable long. Setting it to null disables the limit like MVC's[DisableRequestSizeLimit]
.You can only configure the limit on a request if the application hasn’t started reading yet; otherwise an exception is thrown. There’s an
IsReadOnly
property that tells you if the MaxRequestBodySize property is in read-only state, meaning it’s too late to configure the limit.Global Config Instructions
If you want to modify the max request body size globally, this can be done by modifying a
MaxRequestBodySize
property in the callback of eitherUseKestrel
orUseHttpSys
.MaxRequestBodySize
is a nullable long in both cases. Ex:Please use aspnet/ServerTests#92 for further discussion.
The text was updated successfully, but these errors were encountered: