5

I have just installed the Visual Studio 2013 preview and run up my site. I've noticed that the less files which are used in my site are not being correctly transformed to css and are coming down as blank CSS files.

It appears something is going wrong inside the dotless httphandler as when I force minification for the bundle everything works correctly.

web.config

<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
...
<httpHandlers>
  <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
...
<handlers>
      <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
</handlers>

The issue appears to go away if I force minification eg. System.Web.Optimization.BundleTable.EnableOptimizations = false; which suggests something is different in the way it processes the HTTP handler

undefined
  • 33,537
  • 22
  • 129
  • 198
  • Your `LessTransform` looks [a bit simple](http://stackoverflow.com/questions/15252829/how-to-use-asp-net-mvc-4-to-bundle-less-files-in-release-mode)... – ta.speot.is Jun 29 '13 at 00:30
  • @ta.speot.is The one im currently using seems to work fine, however i tried the one you linked to which is probably more robust and it has the same issue – undefined Jun 29 '13 at 00:34
  • I am encountering the same issue with VS2013 in an MVC 5 project. On the same machine in VS2012 with MVC 4 I get my LESS compiled without issues. – Michael McGuire Jun 30 '13 at 02:55

1 Answers1

7

Try putting handleWebCompression="false" in the configuration for dotless (in the web config)

  <dotless minifyCss="false" cache="true" web="false" handleWebCompression="false" />
Martin Booth
  • 8,485
  • 31
  • 31
  • 2
    that seems to work perfectly, any idea why this only happens in 2013? – undefined Jun 30 '13 at 07:35
  • The problem seems to be with assigning GZipStream as a response filter. I didn't dig too much deeper than identifying which line caused the problem: https://github.com/dotless/dotless/blob/master/src/dotless.AspNet/Response/CssResponse.cs (line 69) – Martin Booth Jul 19 '13 at 04:04
  • 1
    Where in web.config do you place this? – TheOptimusPrimus Nov 19 '13 at 21:23
  • https://github.com/dotless/dotless/wiki/Using-.less explains what needs to go into the web.config (although, if you use the nuget package, this is all added for you). You just need to locate or add the dotless section, and add the handleWebCompression attribute – Martin Booth Dec 19 '13 at 23:50