This project has moved. For the latest updates, please go here.

Debugging HTTP-handlers

As is known, in debug mode Styles.Render and Scripts.Render helper-methods renders a references to individual assets. As a rule, when in the project uses only static CSS- and JS-assets, no problems should arise. But situation changes when in the project added the assets written on intermediate languages (such as LESS and TypeScript). Such assets are not translated and this could lead to the errors in web browser. Therefore, during installation of translators-modules in the Web.config file are automatically registered the debugging HTTP-handlers, that produce translation of requested assets.

When using CustomBundleResolver class opportunities of the debugging HTTP-handlers is significantly expanded: item transformations, translator and postprocessors (property UseInDebugMode of postprocessor must be equals to true) from corresponding bundle will apply to requested asset.

In addition, in BundleTransformer.Core included 2 debugging HTTP-handlers: CssAssetHandler and JsAssetHandler, which applying the transformations from bundle (item transformations and postprocessors) to requested CSS- and JS-assets. If CSS- or JS-asset is not included in the bundle, then CssAssetHandler or JsAssetHandler pass the request to System.Web.StaticFileHandler. Unlike other HTTP-handlers, these HTTP-handlers have to be registered in the Web.config file manually. To use these debugging HTTP-handlers in the IIS Integrated mode, you need add to the /configuration/system.webServer/handlers element the following code:

<add name="CssAssetHandler"
  path="*.css" verb="GET"
  type="BundleTransformer.Core.HttpHandlers.CssAssetHandler, BundleTransformer.Core"
  resourceType="File" preCondition="" />
<add name="JsAssetHandler"
  path="*.js" verb="GET"
  type="BundleTransformer.Core.HttpHandlers.JsAssetHandler, BundleTransformer.Core"
  resourceType="File" preCondition="" />

To use these debugging HTTP-handlers in the IIS Classic mode, you need add to the /configuration/system.web/httpHandlers element the following code:

<add path="*.css" verb="GET"
  type="BundleTransformer.Core.HttpHandlers.CssAssetHandler, BundleTransformer.Core" />
<add path="*.js" verb="GET"
  type="BundleTransformer.Core.HttpHandlers.JsAssetHandler, BundleTransformer.Core" />

Last edited Jan 24, 2015 at 1:19 PM by Taritsyn, version 2