我用过 a template for admin section (bootstrap admin template)在我的项目中并从 Bower
安装它我已经申请了 ASP.NET Core 2
.
当我运行项目时,我收到一个错误:
FileError: 'http://localhost:52125/lib/bootstrap-admin-template/public/assets/less/theme.less' wasn't found (404)
in theme.less
但是文件,
theme.less
, 存在于路径中!!我不知道为什么浏览器无法识别该文件。用于路由
theme.less
我做的文件:<link rel="stylesheet/less" type="text/css" href="~/lib/bootstrap-admin-template/public/assets/less/theme.less">
我该如何解决这个问题?
最佳答案
在 documentation在 StaticFiles 中间件上:
If the user requests a file of an unknown file type, the static file middleware returns a HTTP 404 (Not Found) response.
这似乎就是这里发生的事情。如果您想减少服务,则需要add a mapping为了它:
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".less"] = "plain/text";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});
关于html - 在 ASP.NET Core 2 中的 layout.cshtml 中使用和路由 Less 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49603561/