简体   繁体   English

ASP.NET Core Kestrel RequestSizeLimit是否针对不同用户?

[英]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. 在我们的ASP.NET Core 2.0应用程序中,我们希望大多数用户拥有一个X的RequestSizeLimit ,但是对于某些特殊用户,我们希望将其提高到更高的值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. 该应用程序以反向代理设置托管在IIS后面。

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 ). 尝试检查它,确定哪个用户已被授权,然后检查请求大小(您可以通过检查HttpContext来实现)。 You can achieve it by impleneting own IAsyncActionFilter . 您可以通过实现自己的IAsyncActionFilter来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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