【发布时间】:2021-06-08 17:20:56
【问题描述】:
我试图让响应压缩在 .NET Core 3.1 中工作,但它不起作用。
在ConfigureServices我有以下内容;
public void ConfigureServices(IServiceCollection services)
{
services.AddResponseCompression();
services.AddControllers();
//All my other services
}
我的Configure 如下:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseResponseCompression();
app.UseHttpsRedirection()
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization()
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
})
}
在 Postman 中使用控制器时,我没有看到 Content-Encoding 设置为 gzip;
【问题讨论】:
-
@canton7 对,我删除了我的评论:)
标签: c# .net-core gzip asp.net-core-3.1