如果我的数据库中有预压缩的数据,当我启用了动态压缩时,我如何从控制器返回这些数据?有没有办法告诉iis/mvc核心“不要重新压缩这个”?
如果我只是返回一个文件数据,我假设IIS会重新压缩它并添加内容编码,那么有没有一种安全的方法可以让iis处理所有的压缩(静态和动态),并且仍然告诉它“不,只是为了这个操作,考虑输出是预先压缩的”?
public IActionResult GetImage(int Id)
    {
        var img = Context.Images
            .Single(i => i.Id == Id);
        return new FileContentResult(img.Data, img.MIME); // What could i do if i wanted, just for this action, to have img.Data already compressed in the database, while everywhere else i have it uncompressed and DO want IIS to compress it?
    }发布于 2019-05-04 04:55:34
您可以排除特定的MIME类型。
services.AddResponseCompression(options =>
{
    options.ExcludedMimeTypes = new List<string> { "image/jpeg" };
});对于压缩或不压缩特定操作的更细粒度的控制...我不确定。
https://stackoverflow.com/questions/55976901
复制相似问题