LESS file does not load (404)

有些话、适合烂在心里 提交于 2019-11-29 21:15:33

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>

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.

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.

I faced this error multiple times now and despite adding a mime type i got the same error over and over again.

Then i discovered that adding a mime type just fixes the 406 error code, not 404. It has something to do with privileges i think.

So try to open the file as Administator (like notepad.exe -> run as Administrator) and overwrite the file with itself. This worked for me.

Here is a good video tutorial that should get you started -> http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-you-need-to-check-out-less-js/

EDIT: not really the fix but a small tip. always add type="text/css" when opening style tags or linking to a stylesheet in the link tag.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!