Using and routing Less file in the layout.cshtml in ASP.NET Core 2

馋奶兔 提交于 2019-12-04 21:55:21

In the documentation on the StaticFiles middleware:

If the user requests a file of an unknown file type, the static file middleware returns a HTTP 404 (Not Found) response.

That seems to be what's happening here. If you want to serve less then you need to add a mapping for it:

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".less"] = "plain/text";

app.UseStaticFiles(new StaticFileOptions
{
    ContentTypeProvider = provider
});
Jahan

Apparently, Less files can not be used directly in asp.net core 2 projects. It must first be compiled. In this link you can figure out that how be compiled a Less file.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!