I like to set the MaxRequestBodySize for an API operation depending on a query string parameter when API operation is called.
Let's say, something like that:
[HttpPost("{para1}")]
[RequestSizeLimit(...when para1 = "a" ? 500MB : 50MB)]
public void PostIt(string para1, [FromBody] string bodyContent)
{
// do stuff
}
However, with the RequestSizeLimit attribute this cannot be done, I guess somhow with the middleware it should be possible, but I have to admit, have not found any working solution so far.
Is this technically even possible and how can I achieve the goal?
I'm using .net 6.0