Is there a build-in way to limit the body size per request?

Is there a build-in way to limit the body size per request?

If not, what is the best way to implement this?
Can this be done with RequestFilters?

Currently i use a global solution:

.UseKestrel(opts => {
                    opts.Limits.MaxRequestBodySize = 1024 * 1024 * 1024;  // 1 GB
                })

But i want to limit this to one specific request. I’m happy about any hint.

Br,
Alex

The higher up the web stack the solution the better, e.g. Kestrel/IIS/Nginx.

If you want to limit just a specific ServiceStack Service Request you can do it with:

GlobalRequestFilters.Add((req, res, dto) => {
    if (dto is MyDto && req.ContentLength > 1024 * 1024 * 1024)
    {
        res.StatusCode = (int)HttpStatusCode.RequestEntityTooLarge; //413
        res.EndRequest();
    }
});