在ASP.NET项目中的客户端上处理更少的文件 [英] Processing Less file on client in ASP.NET project

查看:133
本文介绍了在ASP.NET项目中的客户端上处理更少的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从.css更改为.less,并使用less.js在客户端上处理此.less. 因此,我将.css重命名为.less,然后将less.js添加到项目(ASP.NET Web窗体)中.所以头部看起来像这样:

I am trying to change from .css to .less and process this .less on the client using less.js. So I renamed my .css to .less and then added less.js to the project (ASP.NET Web Forms). So the head section looks like this:

<link href="Content/myproject.less" rel="stylesheet/less" type="text/css"/> 
<script src="Scripts/less-1.5.0.min.js"></script>

但是当我运行项目时,出现错误,找不到文件myproject.less.确切的错误是:

But when I run the project I get error that file myproject.less is not found. The exact error is:

FileError: 'http://localhost:52714/Content/myproject.less' wasn't found (404)
in myproject.less

该行(在myproject.less中)允许我单击myproject.less,这将打开错误页面:

The line (in myproject.less) allows me to click on myproject.less which opens the error page:

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. 
If the page is a script, add a handler. If the file should be downloaded, add a 
MIME map.

Most likely causes:
•It is possible that a handler mapping is missing. By default, the static file handler
processes  all content.
•The feature you are trying to use may not be installed.
•The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not 
create a MIME map for content that users should not download, such as .ASPX pages or .config
files.)
•If ASP.NET is not installed.

我的ASP.NET项目缺少什么?

What is missing in my ASP.NET project?

推荐答案

对于遇到相同问题的任何人,我都知道这是一个老问题,但是要解决此问题,只需将以下内容添加到您的web.config中(这将添加一个LESS的mime类型)

For anyone struggling with the same issue, I know this is an old question however to fix it simply add the following to your web.config (Which will add a mime-type for LESS)

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

这篇关于在ASP.NET项目中的客户端上处理更少的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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