使用OWIN进行自托管时是否可以压缩静态文件?
我能够使用库Microsoft.AspNet.WebApi.MessageHandlers.Compression压缩WebAPI响应,并使用以下代码:
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));
但是,我找不到将消息处理程序插入StaticFiles提供程序管道的方法。
当前代码...(应用程序定义为IAppBuilder应用程序,webPath是本地路径)。
FileServerOptions clientOptions = new FileServerOptions()
{
RequestPath = new Microsoft.Owin.PathString(""),
FileSystem = new PhysicalFileSystem(webPath),
EnableDirectoryBrowsing = false
};
app.UseFileServer(clientOptions);