Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LESS file does not load (404)

I'm using IIS 7.5 and I'm unable to load the less file because it gives a 404 error.

HTML:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Less Tutorial</title>
        <link rel="stylesheet/less" href="style.less" />
        <script src="less-1.0.41.min.js"></script>
    </head>
    <body>        
        <div id="container">
            <a href="#">My Anchor</a>
        </div>
    </body>
</html>

LESS:

@primary_color: green;

#container {
    width: 200px;
    height: 200px;
    background: @primary_color;
}
like image 477
Diogo Cardoso Avatar asked Apr 07 '11 09:04

Diogo Cardoso


3 Answers

When using Asp.Net you can add the mime type in your web.config:

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".less" mimeType="text/css" />
  </staticContent >
</system.webServer>
like image 56
Giorgio Bozio Avatar answered Oct 05 '22 04:10

Giorgio Bozio


When using webmatrix go to "Documents\IISExpress\config" open "applicationhost.config" and add the line mimeMap fileExtension=".less" mimeType="text/css" under the section "staticContent". Hope this helps.

like image 44
Geoffrey Avatar answered Oct 05 '22 05:10

Geoffrey


In my MVC 5 application, I tried many of these approaches and couldn't resolve the problem. Ultimately, I installed Web Essentials for VS 2013 and took advantage of the built-in LESS compiler. Every time you save your LESS file, it will generate the corresponding CSS. In my layout, I simply point to the CSS file and worked around my trouble.

like image 21
rictionaryFever Avatar answered Oct 05 '22 04:10

rictionaryFever