C# 如何使用Microsoft.Owin.StaticFiles扩展名压缩静态文件?
使用OWIN自托管时是否可以压缩静态文件 我可以使用库Microsoft.AspNet.WebAPI.MessageHandlers.Compression使用以下代码压缩WebAPI响应:C# 如何使用Microsoft.Owin.StaticFiles扩展名压缩静态文件?,c#,asp.net-web-api2,C#,Asp.net Web Api2,使用OWIN自托管时是否可以压缩静态文件 我可以使用库Microsoft.AspNet.WebAPI.MessageHandlers.Compression使用以下代码压缩WebAPI响应: HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));
但是,我找不到将消息处理程序插入StaticFiles提供程序管道的方法
当前代码…(应用程序定义为IAppBuilder应用程序,网页路径为本地路径)
见此:
FileServerOptions clientOptions = new FileServerOptions()
{
RequestPath = new Microsoft.Owin.PathString(""),
FileSystem = new PhysicalFileSystem(webPath),
EnableDirectoryBrowsing = false
};
app.UseFileServer(clientOptions);