gpt4 book ai didi

asp.net - 在 ASP.NET 项目中处理客户端上的 Less 文件

转载 作者:行者123 更新时间:2023-12-02 18:45:13 25 4
gpt4 key购买 nike

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

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

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

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

该行(在 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.

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

最佳答案

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

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

关于asp.net - 在 ASP.NET 项目中处理客户端上的 Less 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20587765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com