Click here to Skip to main content
12,952,792 members (35,093 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 14 Jan 2014

.LESS Web.config/DotlessConfiguration Options

, 14 Jan 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Many options of the .LESS CSS parser can be set directly from the Web.config file, but many of them are not clearly described. Here is my attempt to document them.


Many options of the .LESS CSS parser can be set directly from the Web.config file, but many of them are not clearly described. Here is my attempt to document them:


Sets the name of the file reader class to use (must implement the dotless.Core.Input.IFileReader interface). Default value is dotless.Core.Input.FileReader.


Indicates if the CSS produced by the .LESS parser should be minified afterwards. You may wish to minify the files for performance reasons, but if you already use the System.Web.Optimization framework for minification, you can leave it off. Default value is false.


Sets the debug mode that prints comments in the console output. Default value is false.


Indicates if the CSS generated from the LESS file should be cached for 7 days by the web browser by setting the HTTP headers, otherwise the CSS file will always be reloaded by the browser. Default value is true.


Indicates if .LESS is running in a web application or from the command line. Depending on the rest of the configuration and the custom logger or file reader you may have used, your web application may work correctly even if the web mode is off. Default value is false.


When .LESS is running as a web application, indicates if the paths should be mapped to the location of the website. Otherwise, the paths are relative to the current directory to allow files outside the web directory structure. Default value is true.


Dotless does not need the session but it may be enabled with this option to use the session in plugins. The possible values are Enabled, QueryParam (see next section) and Disabled, and the default value is Disabled.


When the sessionMode is QueryParam, a parameter must be added to the query string so the session can be used. The name of the parameter can be specified using this option, and the default value is sstate.


Sets the name of the logger to use to log parsing errors (must implement the dotless.Core.Loggers.ILogger interface). It does not work with the Web.config as of .LESS version 1.3.1, but it can be set manually from the DotlessConfiguration object. Default value is null, but two loggers are available: the dotless.Core.Loggers.ConsoleLogger that logs to the Visual Studio console output and the dotless.Core.Loggers.DiagnosticsLogger that logs to the trace listeners used by the current application.


Sets the level at which the parser errors are logged. The possible values are Info, Debug, Warn and Error, and the default value is Error. Please note that no logger is set by default.


.LESS optimizes the parsing of the .LESS file by separating it into chunks and parsing each chunk instead of the whole file at once. If the value is 0, the operation is not optimized, and if the value is larger than 0 the optimization is used. Default value is 1.


Contains the list of .LESS plugins used by the application. Plugins are used to add new functions to .LESS and are created as classes implementing the IFunctionPlugin interface. By default, no plugins are added. To add a plugin:

  <plugin name="PluginClassName" assembly="PluginAssemblyName" />


Indicates if the URLs in the imported files should be adjusted depending on the location of the LESS file importing it. Default value is false.


Indicates that when the file imported by the @import directive is a CSS file, the content of the files should be put in directly in output without trying to parse it as a LESS file instead of keeping the import directive. Default value is false.


Indicates if all imported files should be processed as LESS files even if they end with the .css extension, otherwise only the .less files are processed as LESS. Default value is false.


Indicates if .LESS should handle the compression of the response according to the Accept-Encoding header of the request, otherwise it is not compressed and may be compressed by setting IIS options (the same response should not be compressed twice). The options gzip, deflate and identity are supported for the Accept-Encoding header. The default value is true and the default encoding used is gzip if no compatible compression method is found in the header.


Indicates if the parameters for the query string should be ignored by .LESS, or if the parameters should be defined as a variable inside the LESS file requested by the ParameterDecorator. For example, if parameters are enabled, style.less?param=value will be added as @param: value; in the LESS file (the value should be URL encoded). Default value is false.


Indicates that variables being redefined should be disabled, so less will search from the bottom to the top of the file. This is used to make .LESS behave like Less.js when handling variables. Default value is false.


Indicates that the first comment starting by /** in the LESS file should be kept even after minification. Default value is false.

If you need to use options that do not work from the Web.config, the Less.Parse method can take a DotlessConfiguration object as a parameter. In my case, I already use System.Web.Optimization for minification and bundling of the CSS files, so I created my own bundle transformation class that implements the IBundleTransform interface and calls the parser.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Cindy Potvin
Canada Canada
Cindy Potvin is a software developer based in the Montreal area. At her day job, she creates web applications using the ASP.NET MVC framework and mobile applications using the Android SDK.

You may also be interested in...

Comments and Discussions

QuestionLife saver! Pin
David Bywaters4-Sep-14 0:34
memberDavid Bywaters4-Sep-14 0:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 14 Jan 2014
Article Copyright 2014 by Cindy Potvin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid