代码之家  ›  专栏  ›  技术社区  ›  x19

在布局中使用和路由较少的文件。ASP中的cshtml。净核心2

  •  6
  • x19  · 技术社区  · 8 年前

    我用过 a template for admin section (bootstrap admin template) 在我的项目中,并从 Bower 我已经申请了 ASP.NET Core 2 。

    运行项目时,我会遇到一个错误,即:

    文件错误: ' http://localhost:52125/lib/bootstrap-admin-template/public/assets/less/theme.less ' 找不到(404)

    在主题中。较少的

    但是文件, theme.less ,存在于路径中!!我不知道为什么浏览器无法识别该文件。

    用于路由 主题较少的 我所做的文件:

    <link rel="stylesheet/less" type="text/css" href="~/lib/bootstrap-admin-template/public/assets/less/theme.less">
    

    如何解决此问题?

    The error

    Path of theme.less file

    Tree Structure Of Files and Folders

    2 回复  |  直到 8 年前
        1
  •  10
  •   Chris Pratt    8 年前

    在 documentation 在StaticFiles中间件上:

    如果用户请求未知文件类型的文件,静态文件中间件将返回HTTP 404(未找到)响应。

    这似乎就是这里发生的事情。如果你想少发球,那么你需要 add a mapping 对于it:

    var provider = new FileExtensionContentTypeProvider();
    provider.Mappings[".less"] = "plain/text";
    
    app.UseStaticFiles(new StaticFileOptions
    {
        ContentTypeProvider = provider
    });
    
        2
  •  0
  •   seven-phases-max    8 年前

    显然地 Less 文件不能直接用于 asp.net core 2 项目。必须首先对其进行编译。 在这个链接中,您可以了解如何编译 较少的 文件

    https://docs.microsoft.com/en-us/aspnet/core/client-side/less-sass-fa

    推荐文章