-
Notifications
You must be signed in to change notification settings - Fork 48
ASP.NET 4.X HTTP modules
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:
-
HtmlMinificationModule
. Produces a minification of the response output by using the HTML minification manager . -
XhtmlMinificationModule
. Produces a minification of the response output by using the XHTML minification manager. -
XmlMinificationModule
. Produces a minification of the response output by using the XML minification manager. -
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.
- Core
- External JS and CSS minifiers
- ASP.NET Extensions
- How to upgrade applications to version 2.X
- Additional reading and resources