如何使用Microsoft.Owin.StaticFiles扩展名压缩静态文件?

时间:2015-08-26 17:57:26

标签: c# asp.net-web-api2

使用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);

0 个答案:

没有答案