首先,你需要創建一個HttpHandler處理它:
namespace com.waynehartman.util.web.handlers
{
[WebService(Namespace = "http://waynehartman.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class HttpCompressor : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Code for compressing the file and writing it to the HttpResponse
}
public bool IsReusable
{
get { return true; }
}
}
}
然後,你需要在你的web.config添加處理程序映射:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.css"
type="com.waynehartman.util.web.handlers.HttpCompressor, WayneHartmanUtilitiesLibrary"/>
<add verb="*" path="*.js"
type="com.waynehartman.util.web.handlers.HttpCompressor, WayneHartmanUtilitiesLibrary"/>
</httpHandlers>
</system.web>
</configuration>
什麼版本的IIS您使用的是? – 2010-01-29 18:41:44