简体   繁体   中英

ASP.NET Core Kestrel RequestSizeLimit different for different users?

In our ASP.NET Core 2.0 app we would like to have a RequestSizeLimit of X for most users, but for some special users we'd like to bump it up to a higher value Y > X.

Ie we have this today:

[HttpPost("files")]
[RequestSizeLimit(100_000_000)]
public async Task<ActionResult> Upload(string uploadId, IFormCollection formData)
{
    /* Action body */
}

But we want to apply a higher size limit for some specific users.

How can this be done?

The app is hosted behind IIS in a reverse proxy setup.

You should write own Attribute and Filter. Try checking in it, which user is authorized, then check request size(you can achieve it by checking HttpContext ). You can achieve it by impleneting own IAsyncActionFilter .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM