Lesscss和ASP.NET MVC [英] Lesscss and ASP.NET MVC

查看:112
本文介绍了Lesscss和ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于从ASP.NET网页切换我的网站MVC4,我在使用Lesscss麻烦。

Since switching my site from ASP.NET WebPages to MVC4, I'm having trouble with Lesscss.

CSS +的Javascript行:

CSS + Javascript lines:

<link href="@Url.Content("~/Content/site.css")" rel="stylesheet/less" type="text/css" />
<script src="@Url.Content("~/Scripts/less-1.3.0.min.js")" type="text/javascript"></script>

我不知道什么是错的。该路径是正确的。当您删除从CSS链接'/少正常使用样式表的工作原理。当试图使用Lesscss JS文件,它加载罚款,但没有sylesheet被加载。在IE F12开发工具还证实,样式表没有被加载。

I have NO idea what is wrong. The paths are correct. The stylesheet works when you drop the '/less' from the CSS link to use it normally. When trying to use the Lesscss JS file, it loads fine BUT no sylesheet is loaded. F12 dev tools in IE also confirm that the stylesheet is not being loaded.

任何人都有类似的问题?

Has anyone else had similar issues when using Lesscss with MVC4?

推荐答案

您应该指定的MIME类型在你的web.config少的文件扩展名和使用,在你的链接,如果不是CSS。

You should specify the mime type for the less file extension in your web.config and use that in your link instead if css.

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".less" mimeType="text/css" />
  </staticContent >
</system.webServer>

我个人的东西用带点并在服务器上处理,这是一个更好的方式去。

Personally I thing using dotless and processing this on the server is a better way to go.

另外,不是一个真正的回答你的问题,而只是一个侧面点 - 与MVC4您不再需要@ Url.Content()。 <一href=\"http://www.davidhayden.me/blog/asp.net-mvc-4-the-new-tilde-slash-feature-in-razor-2\">http://www.davidhayden.me/blog/asp.net-mvc-4-the-new-tilde-slash-feature-in-razor-2

Also, not really an answer to your question, but just a side point -- with MVC4 you no longer need @Url.Content(). http://www.davidhayden.me/blog/asp.net-mvc-4-the-new-tilde-slash-feature-in-razor-2

这篇关于Lesscss和ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆