1 parent 140436b commit 8edea81Copy full SHA for 8edea81
1 file changed
AspNetCoreVueMpa.Web/Startup.cs
@@ -47,7 +47,29 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
47
app.UseHsts();
48
}
49
app.UseHttpsRedirection();
50
- app.UseStaticFiles();
+
51
+ app.UseStaticFiles(new StaticFileOptions
52
+ {
53
+ OnPrepareResponse = context =>
54
55
+ var headers = context.Context.Response.Headers;
56
+ var contentType = headers["Content-Type"];
57
+ if (contentType == "application/x-gzip")
58
59
+ if (context.File.Name.EndsWith("js.gz"))
60
61
+ contentType = "application/javascript";
62
+ }
63
+ else if (context.File.Name.EndsWith("css.gz"))
64
65
+ contentType = "text/css";
66
67
68
+ headers.Add("Content-Encoding", "gzip");
69
+ headers["Content-Type"] = contentType;
70
71
72
+ });
73
74
app.UseRouting();
75
0 commit comments