How to Add *.Less to Iis 7.0

How to add *.less to IIS 7.0?

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.

Compile Sass files in IIS7

Firstly Sass is a pre-processor, therefore must to be compiled to CSS to be used by the browser and IIS.

You have a few options:

  1. Compile to css within Visual Studio and add the CSS to the project.

  2. Have your build server/process compile to CSS before deploying to your environment. A common way to do this is with a Grunt or Gulp script.

  3. Use BundleTransformer for Sass and create bundles with your .scss files. The transformer will output the bundle compiled to CSS.

Less stylesheet file 406 on IIS7/discountaspnet

I fixed this in the end....

The 406 error is basically telling you that there was a mismatch between what the browser was expecting and what the server sent it.

In my case it was the fact that my web.config was telling the browser that any files with an extension of .less were to be served as the mime type "text/css".

<staticContent>
<mimeMap fileExtension=".less" mimeType="text/css" />
</staticContent>

Where as, in my site, the file was being declared as "text/less"

<link href="@Url.Content("~/Content/style.less")" rel="stylesheet/less" type="text/less" />

To fix it I changed the "mimeType" setting in the web.config to match the declaration in the page so the web.config section is now:

<staticContent>
<mimeMap fileExtension=".less" mimeType="text/less" />
</staticContent>

I hope that helps!

Cheers

DotLESS IIS7 is not working: LESS is not being rendered

I was having the same problem. What worked for me was putting the following web.config settings under system.webServer, instead of the suggested settings that the .less website shows under system.web:

<system.webServer>
<handlers>
<add name="dotless" path="*.LESS" verb="*" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition=""/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>

Source: http://cyrilgupta.com/?p=520

If you haven't already done so, you also need to add a MIME type for .less files in IIS, which I do not believe is listed in the instructions at dotlesscss.org.

How do I enable upload of large files in classic ASP on IIS 7?

The maxAllowedContentLength controls how much data is allowed to be sent in a response. However you want to control how much can be accepted in a request. This is handled by the maxRequestEntityAllowed attribute of the limits element in the asp section of the config file. An example might look like:-

<system.webServer>
<asp>
<cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
<limits scriptTimeout="00:02:00"
queueConnectionTestTime="00:00:05"
requestQueueMax="1000"
maxRequestEntityAllowed="104857600"
/>
</asp>

You can configure this in the IIS7 manager under the "Limit Properties" category in the property grid for the ASP feature. Alternatively you can use a command line:-

appcmd set config /section:asp /limits.maxRequestEntityAllowed:104857600

Note that extending this value increase the window for DOS attack where the attacker sends large content to the server so don't be tempted to extend this beyond what you really need.



Related Topics



Leave a reply



Submit