Safran Ali Safran Ali - 9 days ago 6
Less Question

How to add *.less to IIS 7.0?

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.

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


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 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:

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.

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.

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.

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