【发布时间】:2022-10-13 00:57:35
【问题描述】:
所以我正在构建一个 asp.net+angular 应用程序,我在其中放置了一个 webgl 统一构建。我正在尝试添加 brotli 压缩,但由于某种原因,在响应标头中,我没有显示 content-encoding 属性,并且我仍然收到以下“提示”:
这是我的 Program.cs:
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using System.IO.Compression;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// CONFIG START
builder.Services.AddControllersWithViews();
builder.Services.AddSpaStaticFiles(config => config.RootPath = "ClientApp/dist"); // ovo je kriticno, path
//builder.Services.Configure<BrotliCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
builder.Services.AddResponseCompression(options =>
{
options.MimeTypes = new[] {
"application/octet-stream",
"application/vnd.unity"
};
options.Providers.Add<BrotliCompressionProvider>();
options.EnableForHttps = true;
});
// CONFIG END
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()){
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
//var provider = new FileExtensionContentTypeProvider();
//provider.Mappings.Remove(".unityweb");
//provider.Mappings.Add(".unityweb", "application/octet-stream");
//app.UseStaticFiles(new StaticFileOptions{
// ContentTypeProvider = provider
//});
app.UseRouting();
app.UseResponseCompression();
app.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}"
);
app.MapFallbackToFile("index.html");
app.Run();
我究竟做错了什么?谢谢!
【问题讨论】:
标签: c# asp.net unity3d response-headers brotli