ASP.NET 4.X HTTP modules - Taritsyn/WebMarkupMin GitHub Wiki

WebMarkupMin.AspNet4.HttpModules works at the level of ASP.NET 4.X, and therefore can be used with any of existing ASP.NET frameworks: Web Forms, MVC and Web Pages. But it is worth noting, that in the MVC and Web Forms applications, we recommend using a more specialized solutions, because HTTP modules do not support caching. Usage of HTTP modules suitable for small web sites written in ASP.NET Web Pages.

WebMarkupMin.AspNet4.HttpModules package contains classes of HTTP modules, which give the possibility to minify and compress the code generated by ASP.NET:

  1. HtmlMinificationModule. Produces a minification of the response output by using the HTML minification manager .
  2. XhtmlMinificationModule. Produces a minification of the response output by using the XHTML minification manager.
  3. XmlMinificationModule. Produces a minification of the response output by using the XML minification manager.
  4. HttpCompressionModule. Produces a HTTP compression of the response output with text content type by using the HTTP compression manager.

HTTP modules, that you want to use, you need to register in the Web.config file:

<?xml version="1.0"?>
<configuration>
    …
    <system.webServer>
        <modules>
            <add name="HtmlMinificationModule"
                type="WebMarkupMin.AspNet4.HttpModules.HtmlMinificationModule, WebMarkupMin.AspNet4.HttpModules" />
            <add name="XhtmlMinificationModule"
                type="WebMarkupMin.AspNet4.HttpModules.XhtmlMinificationModule, WebMarkupMin.AspNet4.HttpModules" />
            <add name="XmlMinificationModule"
                type="WebMarkupMin.AspNet4.HttpModules.XmlMinificationModule, WebMarkupMin.AspNet4.HttpModules" />
            <add name="HttpCompressionModule"
                type="WebMarkupMin.AspNet4.HttpModules.HttpCompressionModule, WebMarkupMin.AspNet4.HttpModules" />
        </modules>
        …
    </system.webServer>
    …
</configuration>

To use these HTTP modules in the IIS Classic mode (this also applies to the XSP web server for Mono), they must be declared inside the /configuration/system.web/httpModules element:

<?xml version="1.0"?>
<configuration>
    …
    <system.web>
        <httpModules>
            <add name="HtmlMinificationModule"
                type="WebMarkupMin.AspNet4.HttpModules.HtmlMinificationModule, WebMarkupMin.AspNet4.HttpModules" />
            <add name="XhtmlMinificationModule"
                type="WebMarkupMin.AspNet4.HttpModules.XhtmlMinificationModule, WebMarkupMin.AspNet4.HttpModules" />
            <add name="XmlMinificationModule"
                type="WebMarkupMin.AspNet4.HttpModules.XmlMinificationModule, WebMarkupMin.AspNet4.HttpModules" />
            <add name="HttpCompressionModule"
                type="WebMarkupMin.AspNet4.HttpModules.HttpCompressionModule, WebMarkupMin.AspNet4.HttpModules" />
        </httpModules>
        …
    </system.web>
    …
</configuration>

Because HTTP modules do not support caching, it is not recommended to use them for high-loaded sites.

⚠️ **GitHub.com Fallback** ⚠️