IIS6中的ASP.NET MVC压缩选项 [英] ASP.NET MVC compression options in IIS6

查看:124
本文介绍了IIS6中的ASP.NET MVC压缩选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我坚持使用IIS6的ASP.NET-MVC(因为我无法升级到Server 2008)。



我的所有旧的.aspx文件都是压缩的(如在Fiddler中看到的),但是我的RESTful URL是动态文件,而不是压缩它们。不是'/ products / 1001'键入URLS。



有什么办法让IIS6压缩我的ActionResults在IIS6中,不使用像 ActionFilter for compression



我假设IIS7很聪明,知道他们是动态的。

如果你能告诉我IIS6甚至知道哪些文件是动态的,那么奖金点是第一个!

解决方案

由于ASP.NET的HTTP压缩通常使用HttpModules从版本1.0开始实现,并且HttpModules仍然属于MVC框架使用的ASP.NET请求管道,您仍然可以使用HttpModule注入GZIP



在这里你可以找到一个非常好的,开源的,准备发货的实现:
Ben Lowery的HttpCompress (下载地址: Google代码



您只需添加对DLL的引用,并在您的web.config中添加几行。它已经处理非常奇特和罕见的情况和例外。你可以添加排除到你的web.config,而不是基于文件扩展名(如在IIS6中),但在mime类型,这可能是你需要的。



应该补充说,我实际上在IIS6上使用这个库运行一个ASP.NET MVC网站,所以我可以确认这在实践中是有效的。


For now I'm stuck with IIS6 for ASP.NET-MVC (as in I cant upgrade to Server 2008 yet). It doesnt seem to know that my RESTful URLS are dynamic files and isn't compressing them.

All my old .aspx files are compressed (as seen in Fiddler), but not the '/products/1001' type URLS.

Is there any way to get IIS6 to compress my ActionResults in IIS6 without using something like an ActionFilter for compression.

I'm assuming IIS7 is clever enough to know they're dynamic right.

Bonus points if you can tell me how IIS6 even knows which files are dynamic in the first place!

解决方案

As HTTP compression for ASP.NET usually has been implemented using HttpModules since version 1.0, and HttpModules still belong to the ASP.NET request pipeline used by the MVC framework, you can still use a HttpModule to inject a GZIP or deflate response filter.

Here you can find a very nice, open-source, ready to ship implementation: HttpCompress by Ben Lowery (download at Google Code)

You just have to add a reference to the DLL, and add a few lines to your web.config. It already handles very exotic and rare cases and exceptions. You can add exclusions to your web.config, not based on file extensions (like in IIS6), but on mime type, which is probably exactly what you need.

I should add that I have actually running a ASP.NET MVC website on IIS6 using this library, so I can confirm that this works in practice.

这篇关于IIS6中的ASP.NET MVC压缩选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆