如何将 *.less 添加到 IIS 7.0? [英] How to add *.less to IIS 7.0?

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

问题描述

我在本地机器上设置了一个虚拟应用程序,它正在运行,但它没有加载 CSS 文件.我正在使用 lessCSS 来设置我的应用程序的样式,我认为这里不加载 css 的原因是 LESSCSS 样式sheet 使用 .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 Header Field 来指示文件的内容是哪种格式.例如,当它们提供静态 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.

如果网络服务器不知道请求扩展名,它们会搜索以查看是否已经安装了另一个知道该扩展名的应用程序.如果有另一个应用程序,则他们让该应用程序提供文件.

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.Chef 已经(从字典中)知道 Graboori 只是 Pizza 的另一个名称.因为他知道如何提供比萨饼,所以他只是提供.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆