I've tried using an answer from IIS: How to serve a file without extension?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".*" mimeType="text/plain" />
</staticContent>
</system.webServer>
</configuration>
Which is letting me target the file, but not access it
HTTP Error 404.3 - Not Found
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.
Try this
<staticContent>
<mimeMap fileExtension="." mimeType="text/html" />
</staticContent>
Related
I am developing a new site in Umbraco 7.2.8.
I need display google maps in the site, I have the kml file with all information and the js file to process the information, but when I load the file in front-end I have the error "GET http://myserver/Scripts/agencias.kml?=1443806128026 404 Not Found"
"NetworkError: 404 Not Found - http://myserver/Scripts/agencias.kml?=1443806128026"
How I can activate or display the kml file?
Thanks
You can add the .kml extension to web.config
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".kml" />
<mimeMap fileExtension=".kml" mimeType="application/vnd.google-earth.kml+xml" />
</staticContent>
</system.webServer>
</configuration>
I have a temporary directory at:
c:\inetpub\mysite\temp\
I build a text file dynamically and save it to that directory. Then I have the users browser download that file by putting it into an iframe. This works fine for files that the browser can't open (.doc, .zip) but because I'm using a .txt file the browser just opens it. e.g. It never goes through the normal download process where you can pick where you want to have it downloaded.
A little research and I found you can put a web.config in the same directory as the file to configure the HTTP headers and then do something like:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".txt" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
But when I do that I get Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.txt' So I'm guessing at a web.config at a parent level is already setting the MIME type for .txt.
Is there a way to set the MIME type for static content in a leaf directory (or for a specific directory) using a web.congig file?
I found it. You have to remove the other one before adding.
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".txt" />
<mimeMap fileExtension=".txt" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
I've got a test Wordpress site running in Azure as an Azure Website using the Wordpress install from the Azure gallery.
The site is functional and appears to be working as expected. With one exception. I'm using a custom webfont - http://fortawesome.github.io/Font-Awesome/.
This font has an OTF, SVG, TTF, EOT and WOFF version. From what I understand different devices/browsers use different versions of the file to render to the font.
I'm having a problem serving the .woff version of the file.
I have turning on the logging within the Azure portal and I can see the following error
SECURITY_DENIED_BY_MIMEMAP
FileName
C:\DWASFILES\SITES\WWW-MYWPTESTSITE\VIRTUALDIRECTORY0\SITE\WWWROOT\WP-CONTENT\THEMES\AVADA\AVADA\FONTS\FONTAWESOME-WEBFONT.WOFF
I have confirmed that the .woff file exists on the server by logging into via SFTP and browsing to the folder.
I have seen other posts online about adding this information to the web.config file. Something like:
<?xml version="1.0"?>
<!-- Web.Config Configuration File -->
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
</staticContent>
</system.webServer>
</configuration>
However, I'm not sure how this can, or should, be added to the Azure hosted site.
UPDATE: Save the above code as web.config and upload to the wwwroot folder. Azure will now allow the .woff font to be downloaded when requested.
Save the following as web.config. Upload the web.config file to the wwwroot folder of the site hosted in Azure. The .woff files will now be served.
<?xml version="1.0"?>
<!-- Web.Config Configuration File -->
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
</staticContent>
</system.webServer>
</configuration>
I have encountered a completely unexpected behavior when adding a mimeMap element for files with mp3 extensions. This works fine:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<mimeMap fileExtension=".ogg" mimeType="audio/ogg" />
<!-- <mimeMap fileExtension=".mp3" mimeType="audio/mpeg" /> -->
</staticContent>
</system.webServer>
But as soon as I uncomment the element pertaining to MP3 files, everything goes to hell in a proverbial handbasket. Neither my js nor my css nor my aspx files will be served, and I get lots of these:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Anyone seen this behavior before, or have any pointers? I am (clearly) less than adept in IIS configuration.
this behavior might be because.. In IIS the mimetype for mp3 is already configured.
you adding in web.config mimemap for mp3 will cause duplicate entry.
just do
<remove fileExtension=".mp3"/>
<mimeMap fileExtension=".mp3" mimeType="audio/mpeg" />
regards
Goutham Ganesh V
I would like to set up rules in IIS7 for static content caching in my ASP.NET website.
I have seen these articles, which details how to do it using the <clientCache /> element in web.config:
Client Cache <clientCache> (IIS.NET)
Add Expires or Cache Control Header to static content in IIS (Stack Overflow)
However, this setting appears to apply globally to all static content. Is there a way to do this just for certain directories or extensions?
For example, I may have two directories which need separate cache settings:
/static/images
/content/pdfs
Is it possible to set up rules for sending cache headers (max-age, expires, etc) based on extensions and folder paths?
Please note, I must be able to do this via web.config because I don't have access to the IIS console.
You can set specific cache-headers for a whole folder in either your root web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Note the use of the 'location' tag to specify which
folder this applies to-->
<location path="images">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
</staticContent>
</system.webServer>
</location>
</configuration>
Or you can specify these in a web.config file in the content folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
</staticContent>
</system.webServer>
</configuration>
I'm not aware of a built in mechanism to target specific file types.
You can do it on a per file basis. Use the path attribute to include the filename
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="YourFileNameHere.xml">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
</configuration>
I had the same issue.For me the problem was how to configure a cache limit to images.And i came across this site which gave some insights to the procedure on how the issue can be handled.Hope it will be helpful for you too
Link:[https://varvy.com/pagespeed/cache-control.html]