Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ASP.NET项目中客户端处理较少的文件_Asp.net_Less - Fatal编程技术网

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

在ASP.NET项目中客户端处理较少的文件,asp.net,less,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&

我正在尝试从.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>
行(在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项目缺少什么

再次检查myproject.less文件是否设置为复制到输出或复制到项目文件的内容目录中

首先,检查myproject.less是否实际存在于构建输出中;如果没有,请在下面继续

在Visual Studio中打开项目后,左键单击myproject.less,然后检查“属性”窗口。有两个重要的属性需要查找:

  • 构建操作-如果设置为内容,则可能会在构建输出中复制文件,并使其可用于web应用程序;如果不是,很可能不会
  • 复制到输出目录-此选项覆盖上述生成操作行为,并将确保文件将显示在生成输出中,并可在web应用程序中使用

尝试将“复制到输出目录”设置为true,看看是否可以修复它。学习这些技术是确保您的web应用程序正常运行的关键。

对于遇到相同问题的任何人来说,我知道这是一个老问题,但要解决它,只需将以下内容添加到您的web.config(这将以更少的成本添加mime类型)



阅读错误信息并执行其中提供的说明如何?J.Polfer。我不知道如何以及在何处检查.less文件是否设置为输出到内容目录。在ASP.NET项目中,我在哪里检查它?谢谢你。波尔弗。非常感谢你。我发现动作和复制都没有按照你的建议设置。所以我改了。这很可能会解决问题,但同时我遇到了另一个问题(使用Ajax),它阻止我执行。但我会尽我所能。在基于ASP.NETCore2的项目中如何?项目类型中没有web.config。
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.
<system.webServer>  
   <staticContent>
      <mimeMap fileExtension=".less" mimeType="text/css" />
   </staticContent>
</system.webServer>