本文介绍了如何添加* .less到IIS 7.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的localmachine上设置了一个虚拟应用程序,它正在运行,但它不加载CSS文件。我使用来设置我的应用程序样式,我认为这里没有加载CSS的原因是LESSCSS样式表使用.less扩展。

I have set up a virtual application on my localmachine and it is running but it's not loading the CSS file. And I am using the lessCSS for styling my application and I think the reason here for not loading the css here is that LESSCSS style sheet uses .less extension.

那么,为了读取* .less文件扩展名,该怎么办?

So what to do in order to read *.less file extension?

推荐答案

没有必要添加处理程序。只需为 .less 添加MIME类型(现在称为Internet媒体类型),并将MIME类型设置为 text / css

There is no need to add a handler. Just add a MIME type (now known as Internet Media Type) for .less and set the MIME type to text/css.

Web服务器查看请求的扩展名(就像文件扩展名一样)。如果他们知道扩展名,他们将提供该文件,并添加一个HTTP头字段,以指示文件的内容采用哪种格式。例如,当他们提供静态HTML文件时,他们添加 Content-Type:text / html 头字段。这样,浏览器可以理解使用哪个应用程序处理响应体。

Web servers see the extension of requests (just like extensions of files). If they know the extension, they serve the file, and add an HTTP Header Field to indicate that the content of the file is in which format. For example, when they serve static HTML files, they add Content-Type: text/html header field. This way, browsers can understand to use which application for processing the body of response.

如果Web服务器不知道请求扩展,他们搜索以查看是否有已经安装在他们上知道扩展名的另一个应用程序。如果有另一个应用程序,那么他们让该应用程序提供该文件。

If web servers don't know the request extension, they search to see if there is already another application installed on them which knows the extension. If there is another application, then they let that application serve the file.

您可以想到这个例子来充分理解会发生什么:

You can think of this example to fully understand what happens:

您去一家餐厅,(您是 HTTP请求)。你要求一个披萨(披萨是扩展)。

You go to a restaurant, (you are the HTTP request). You ask for a pizza (pizza is the extension). The chef knows how to serve pizza, thus it serves you.

现在考虑你再次去同一家餐馆,要求 Bomyhoor (一种假食品)。厨师不知道如何做饭和服务。他/她要求其他厨师看看厨房里是否已经有其他人(厨房是网络服务器)谁知道如何做饭?如果有人知道要烹饪 Boomyhoor ,那么他/她为你服务。

Now consider that you go to the same restaurant another time, and ask for Bomyhoor (a fake food). Chef doesn't know how to cook and serve that. He/she asks other cooks to see if there is already someone else in the kitchen (kitchen is the web server) who knows how to cook that? If someone knows ho to cook Boomyhoor, then he/she serves you.

现在,时间,这次请求 Graboori 。厨师已经知道(从字典) Graboori 是披萨的另一个名字。

Now, consider that you go another time, and this time ask for Graboori. Chef already knows (from a dictionary) that Graboori is just another name for Pizza. Because he knows how to server pizza, he simply serves that.

当您将MIME类型添加到Web服务器时,只需将请求扩展名映射到文件类型即可。

When you add a MIME type to a web server, you simply map a request extension to a file type.

这篇关于如何添加* .less到IIS 7.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 07:32