1

I'm trying to use less in my new project. I've installed dotLess and System.Web.Optimization.Less packeges (as described in Yet Another "Add LESS to your ASP.NET MVC Project" Post) and locally everything works fine. But when I publish project IIS7 server responds with empty css file /Content/Main/site?v=

Here is my web.config

...

<configSections>
  <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
</configSections>

<system.web>
  <httpHandlers>
  <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
</system.web>

<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <handlers>
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    <add name="dotless" path="*.LESS" verb="*" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition=""/>
  </handlers>
</system.webServer>

<dotless minifyCss="false" cache="true" web="false" />

And my BundleConfig.cs

bundles.Add(new LessBundle("~/Content/Main/site").Include("~/Content/Main/Site.less"));

When I append css extension to my Site.less file (Site.less.css) server responds with content (/Content/Main/site?v=K-FFpFNtIXPUlQamnX3qHX_A5r7TM2xbAgcuEmpm3O41) but it still pure less with all its variables and etc.

The same with Bundle Transformer: Sass and SCSS

What have I missed?

2 Answers 2

1

As you are getting

/Content/Main/site?v=K-FFpFNtIXPUlQamnX3qHX_A5r7TM2xbAgcuEmpm3O41

then this means that the bundling is working correctly. Therefore there is probably something in Site.less that is causing the problem. One thing to watch out for is relative urls. For example if you have an image in your css

.bacon {
    background-image: url(bacon.png);
}

The bundle will look for this with ~/Content/Main taken from the name of the bundle. (/site is fine and can be anything, it's just the name of the bundle)

The first thing to try is take out any imports, images etc and see if it bundles correctly. You can do this on your local dev build by enabling optimizations in the your bundle config.

BundleTable.EnableOptimizations = true
Sign up to request clarification or add additional context in comments.

1 Comment

I've removed all the less and leave only the body{ font-family: Arial; } but still get empty site?v=
0

Another way to solve this is to remove dependency on System.Web.Optimization.Less and dotLess and use free Visual Studio Extension https://github.com/madskristensen/WebCompiler for precompilation of less to css (with and without minification).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.