Less stylesheet file 406 on IIS7/discountaspnet - css

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,

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

Related

Why does my ASP.NET webpage throw custom 404 error with certain file extensions

So, I have a folder on my server such like this:
You can access this resources by the URL:
Image:
Text:
But the kmz, instead of opening the file (maybe like the text in the xml, I'm not expecting to visualize it) it returns a strange 404:
Is there any way of allowing all files to be accessed without an error?
Thank you very much.
As far as I know, if you wants to access the kmz file in the browser, you will face 404.3 error.
Error details:
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
To solve this issue, you should add the MIME map for kmz file.
I suggest you could add below config file into the web.confil, then it will work well.
<system.webServer>
<staticContent>
<remove fileExtension=".kml" />
<mimeMap fileExtension=".kml" mimeType="application/vnd.google-earth.kml+xml" />
<remove fileExtension=".kmz" />
<mimeMap fileExtension=".kmz" mimeType="application/vnd.google-earth.kmz" />
</staticContent>
</system.webServer>

Cant access a file from azure website

http://abcds.azurewebsites.net/scripts/abdsk.json
This file is available in the azure. But when i go to "http://abcds.azurewebsites.net/scripts/abdsk.json" i get a response back saying
GET http://abcds.azurewebsites.net/scripts/abdsk.json 404 (Not Found)
What might be the cause?
By default, Azure won't serve certain file types. You have to explicitly include the MIME type in order for Azure to serve the file.
In your Web App's web.config, add the following in the section:
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>

Roxy Fileman with CKEditor doesn't work after upload to server

I have to use any file manager on my website. I chose Roxy Fileman, because it is compatible with CKEditor, which is my main text editor. The problem is, everything works when i test it on my localhost, but after publishing it on server I get error message: "The page cannot be displayed because an internal server error has occurred." There's no more info... Have you guys any idea what I should do?
1) make sure Fileman folder is added to the directory
2) go to Fileman folder and in web.config add below code into the staticContent tag
<!--Cache static content for 24 hours-->
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="24.00:00:00" />
<!--Allow json file loading (used by Roxy Fileman)-->
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
3) and finaly make sure Fileman has permission to write data
I had the same exact problem and after much research and diagnosing, this worked for me.
In the fileman directory, there is a web.config file. Open it in your text editor and you will see the following line:
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
Delete it from the web.config and save. It is conflicting with something on the live server where this configuration is already being set. I hope this helps anyone.

Possible to add MIME type to web.config without possibly breaking the site?

I had a web.config in one of the websites on my IIS that was adding a support for .7z file extension. When I later added a global .7z support at the server level, this site was broken - IIS Manager is complaining that it "cannot add duplicate collection entry of type 'mimeMap'..." and all web requests to i.g. CSS files ended with an HTTP 500 error.
I was using this in the site's web.config:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />
</staticContent>
</system.webServer>
Is there maybe some other syntax that would add 7z to the list only if it wasn't defined yet?
According to this, you should remove the global setting in the special config before adding it in a different form.
Explcitly:
<system.webServer>
<staticContent>
<remove fileExtension=".7z" />
<mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />
</staticContent>
</system.webServer>
Of course this doesn't really help you now as you might just as well drop the local setting completely (as it's likely to coincide with the global setting). But if you had known this back when you added local 7zip support, you wouldn't have encountered the error now ...

Add MIME mapping in web.config for IIS Express

I need to add a new MIME mapping for .woff file extensions to IIS Express.
If I add the following snippet to the "applicationhost.config" of IIS Express it works fine:
<staticContent lockAttributes="isDocFooterFileName">
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
...
But I would actually like to do add it to my "web.config" so that not every developer would need to change their "applicationhost.config" locally.
So I removed it again from the "applicationhost.config" file and added the following snippet to the project's "web.config":
<system.webServer>
...
<staticContent>
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
</staticContent>
</system.webServer>
Unfortunately it doesn't seem to work that way because when I try to access a .woff file I end up with a HTTP 404.3 error.
What am I doing wrong?
Putting it in the "web.config" works fine. The problem was that I got the MIME type wrong. Instead of font/x-woff or font/x-font-woff it must be application/font-woff:
<system.webServer>
...
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
See also this answer regarding the MIME type: https://stackoverflow.com/a/5142316/135441
Update 4/10/2013
Spec is now a recommendation and the MIME type is officially: application/font-woff
If anybody encounters this with errors like
Error: cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute
and/or other scripts stop working when doing this fix, it might help to remove it first like this:
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
At least that solved my problem
<system.webServer>
<staticContent>
<remove fileExtension=".woff"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
</staticContent>
</system.webServer>
I know this is an old question, but...
I was just noticing my instance of IISExpress wasn't serving woff files, so I wen't searching (Found this) and then found:
http://www.tomasmcguinness.com/2011/07/06/adding-support-for-svg-to-iis-express/
I suppose my install has support for SVG since I haven't had issue with that. But the instructions are trivially modifiable for woff:
Open a console application with administrator privilages.
Navigation to the IIS Express directory. This lives under Program Files or Program Files (x86)
Run the command:
appcmd set config /section:staticContent /+[fileExtension='woff',mimeType='application/x-woff']
Solved my problem, and I didn't have to mess with some crummy config (like I had to to add support for the PUT and DELETE verbs). Yay!
Thanks for this post. I got this worked for using mustache templates in my asp.net mvc project
I used the following, and it worked for me.
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mustache" mimeType="text/html"/>
</staticContent>
</system.WebServer>
I'm not using IIS Express but developing against my Local Full IIS 7.
So if anyone else get's here trying to do that, I had to add the mime type for woff
via IIS Manager
Mime Types >> Click Add link on right and then enter
Extension: .woff
MIME type: application/font-woff
To solve the problem, double-click the "MIME Types" configuration option while having IIS root node selected in the left panel and click "Add..." link in the Actions panel on the right. This will bring up the following dialog. Add .woff file extension and specify "application/x-font-woff" as the corresponding MIME type:
Follow same for woff2 with application/x-font-woff2
I was having a problem getting my ASP.NET 5.0/MVC 6 app to serve static binary file types or browse virtual directories. It looks like this is now done in Configure() at startup. See http://docs.asp.net/en/latest/fundamentals/static-files.html for a quick primer.

Resources