Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Less stylesheet file 406 on IIS7/discountaspnet

I have a site, http://www.allampersandall.com that i'm trying to post up to discountasp.net. It runs great locally in VS2010 debug, but when i post it up all my .less files HTTP 406.

When i looked up HTTP 406, it says its the browser not accepting it-- but why would it run locally but not up on live?

Any ideas?

Thanks,

like image 615
Micah Avatar asked Sep 26 '11 16:09

Micah


1 Answers

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

like image 181
wheelibin Avatar answered Nov 12 '22 14:11

wheelibin