在ASP.NET项目中在客户端上处理更少的文件

Hid*_*lgo 3 asp.net less

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

<link href="Content/myproject.less" rel="stylesheet/less" type="text/css"/> 
<script src="Scripts/less-1.5.0.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

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

FileError: 'http://localhost:52714/Content/myproject.less' wasn't found (404)
in myproject.less
Run Code Online (Sandbox Code Playgroud)

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

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.
Run Code Online (Sandbox Code Playgroud)

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

Jan*_*anR 5

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

<system.webServer>  
   <staticContent>
      <mimeMap fileExtension=".less" mimeType="text/css" />
   </staticContent>
</system.webServer> 
Run Code Online (Sandbox Code Playgroud)