Я использую asp. net core 3.1, и часть моего приложения отображает svg формат файла. У меня нет проблем с SVG формат файла, и он работает правильно. но поскольку мои svg файлы имеют большой размер, я решил использовать формат файла svgz . но после включения сжатия ответа в ASP. NET Core все еще файлы svgz не отображаются на стороне клиента.
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<PlantimsDbContext>(options =>
options.UseNpgsql(Environment.GetEnvironmentVariable("PlantimsV2Cnn"))
);
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "../client-webapp/build";
});
services.AddControllers();
//ّ*****NOTE!!!*****//
services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<GzipCompressionProvider>();
});
//ّ*****NOTE!!!*****//
services.AddSignalR();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseResponseCompression(); //ّ*****NOTE!!!*****//
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHub<UnitMonitorHub>("/unitMonitorHub");
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "../client-webapp";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
}
}