LessAssetHandler is not invoked for path inside area

189 Views Asked by At

I have a problem with LessAssetHandler which ships with BundleTransformer.Less library. I use LessAssetHandler in debug mode as a HttpHandler for transforming less files. Everything works fine except that the files inside ASP.NET areas are not handled by LessAssetHandler. For example file /Content/Style/page.less is handled by LessAssetHandler, byt for file /Areas/Admin/Content/Style/page.less this handler is not invoked. I have configured handler in the folling way:

<system.webServer>
  <handlers>
    <add name="LessAssetHandler" path="*.less" verb="GET"  type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less" resourceType="File" preCondition="" />
  <handlers>
</system.webServer>

How can I force MVC to route less files from area through LessAssetHandler?

1

There are 1 best solutions below

0
On

Registration of LessAssetHandler is correct. The exact same code is added to Web.config file during installation of NuGet package.

BundleTransformer.Less can work in ASP.NET MVC application with areas. It is possible, that you have incorrectly registered the bundle.

Bundle registration should look like the following:

var adminStylesBundle = new CustomStyleBundle("~/Bundles/AdminStyles");
adminStylesBundle.Include("~/Areas/Admin/Content/Style/page.less");
adminStylesBundle.Orderer = nullOrderer;
bundles.Add(adminStylesBundle);