Google Earth (.kmz) mime type IIS issue - iis

I am experiencing a peculiar issue with IIS and KMZ files. I have added the MIME type to IIS and it works just fine -- however, seemingly randomly the MIME type is removed. This has happened a few times now, and each time all I have to do to fix the issue is just add the MIME type again.
The issue is identified when broken links are reported, and as soon as I add the MIME type back in all is well.
Any thoughts on what is causing it, or methods for finding out what's causing it?
Thanks!

My guess is that someone is overwriting or modifying your web.config file. You can modify the web.config using either the IIS server tools or by publishing the project containing the web.config file. If you are modifying your IIS settings using IIS Manager, then every time someone re-publishes the web application it changes those settings. Make sure the correct settings are saved in your web.config in your root VisualStudio project. So that whenever that project is published it's setting the correct IIS settings.
<configuration>
<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>
</configuration>

Related

Updating Azure App Service web.config to load .ttf font files

Wracking my brain but can't seem to find the solution. I have a .ttf font file, located on Azure storage blob, being used for a custom font on my Azure App Service site. I get a 404 "resource not found" error for this file.
After reading a ton of documentation on this, it seems I need to add a couple of lines of code, for a new "mimetype", to the web.config file. Older versions of Azure had this in "Extensions" or "Application Settings".
Other people show the ability to do so in Kudu under the "Debug" option. However, I can't seem to find either of those - "Configuration" shows environment variables and I don't see a "Debub" option in my Kudu portal.
Kudu Console without "Debug" option
How do I actually update the web.config file or at the very least be able to load a .ttf file???
Go to Kudu, then go to wwwroot folder and edit web.config file with the following, or just create one in case it's not there:
PS: previous image shows LogFiles folder, but it should be wwwwroot
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

Can't get SVG served from Azure

I'm building a static HTML5 web site on VS2014 and deploying via Dropbox to be hosted on Azure. All works using F5 on VS2014. But my SVG images do not get served from Azure. I get HTTP/1.1 404 Not Found errors. I have tried this solution:
Use SVG in Windows Azure Websites and the code snippet suggested by Mads Kristensen at http://madskristensen.net/post/prepare-webconfig-for-html5-and-css3. My web.Debug.config & web.Release.config files are both as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<staticContent>
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Here's the question. What should I do to get my svg files to download?
EDIT: I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.
I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.

How to include a non-standard font-face in azure hosted website without using visual studio?

Trying to use a custom font in a simple static content website publish via git to azure. The website project isn't wrapped in a Visual studio solution. There is no web.config so how can I get the custom font to work or any static content such as .json files to be accessible?
This solution implies your using visual studio which I am not. How to include a non-standard font-face in azure?
My exact error is:
Failed to load resource: the server responded with a status of 404 (Not Found) http://fakewebsitename.azurewebsites.net/fonts/fontawesome-webfont.woff?v=4.0.3
you just have to add a MIME type for the font in your web.config it will look something like this for your woff font
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
</system.webServer>
</configuration>
IIS by default will prevent download of static files you don't specify MIME types for.
Edit: added <remove fileExtension=".woff" /> based on #TealFawn suggestion

IIS only add MIME if not exist

I have - again - a problem in my WebAPI application.
I am trying to deploy on different versions of IIS (7, 7.5, 8). Newer versions seem to have a global MIME handler for .json, while older versions don't.
When IIS finds no MIME handler, the file does not exist. So, for the older version I made a local MIME handler in web.config.
The tricky part is: if it finds two of them (one global and one local), it stops working - even if they both are the same, IIS does not know which one to choose (wtf!?) and only throws errors.
Is there a switch I can apply in web.config which states that the MIME is only to be used if there is no other MIME for this extension available?
If not, can I tell VisualStudio to deploy different versions of web.config, depending on the deployment profile - and/or can I apply a IIS-version-based switch in web.config?
The easiest way to deal with this is to use the remove option for a mime mapping like this:
<system.webServer>
...
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
It's discussed in detail here:
http://blogs.msdn.com/b/chaun/archive/2009/12/04/iis7-error-cannot-add-duplicate-collection-entry-of-type-mimemap-with-unique-key-attribute-fileextension.aspx
There's also a reference to it here:
Add MIME mapping in web.config for IIS Express

iis 7 + http custom handler error: could not load file or assembly The system cannot find the file specified

Windows vista 32 bit - C# - .NET 4 - sqlite - IIS 7
I'm building a small project that contains is a custom HTTP handler where an user can request a XML file and the project will generate the file and send it to the user. It should be flexible enough to send something else too like e.g. json.
Everything was going well until I had to deploy the handler. I've created a library (dll) file which contains the logic for serving of the requested information. I've open IIS manager and I've created a virtual directory to the debug bin file (later on i made it an application. it did not make a difference).
I've followed countless examples and tutorials like these ones:
I started with this one: http://support.microsoft.com/kb/308001
http://msdn.microsoft.com/en-us/library/bb515343.aspx
msdn.microsoft.com/en-us/library/46c5ddfy.aspx
But with no luck. As you could have read I'm not using any asp.net website even though I do have a web.config that I've added to the bin folder and it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<directoryBrowse enabled="false" />
<handlers accessPolicy="Read, Script, Execute">
<add name="LigoManagedHandler" path="*" verb="*" type="Ligo.Service, Ligo" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
When I try to run handler in the browser get the following error:
Could not load file or assembly 'Ligo' or one of its dependencies. The system cannot find the file specified.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Ligo' or one of its dependencies. The system cannot find the file specified.
I have tried so many possible combination in IIS manager to get it working ('httphandlers', 'classic mode' and so on ...) but i'm truly stuck. The information I've found on the internet is not helping much.
What am I doing wrong or missing to make it work?
Something in this rant triggered an idea, an I stumbled on the answer.
The line in all those tutorials that say put type="ClassName, AssemblyName" into the Handlers section in Web.Config are plain WRONG.
All I did was change this to type="AssemblyName.ClassName" and everything started working, in both a Web Site Project and a Web Application Project that I had created.
I'm running IIS 7.5 in integrated mode so YMMV.
Craig
I figure it out. I had to make a asp.net website project and add my dll as reference to this project.
I read this thread that provided this information which is not clear on the internet.
http://forums.asp.net/t/1088861.aspx/1?What+causes+the+quot+Could+not+load+type+quot+problem+
It should state that it is not possible to make the httphandler without a aspnet website project. or am i mistaken? the example on the internet are incorrect! or provide too little information.
I know, this is an old thread. However, I've been looking for an answer for a few days without finding a clear one. So, in case anyone comes across similar scenario.
You can create custom Http Handler as a stand-alone Class Library project and use it in IIS.
On IIS Add new Application with ASP4 Integrated mode. Place your compiled DLL into bin folder (this is what i was missing all along). Seems obvious that it should be there; took some time to figure this out. :)
web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<handlers>
<add verb="*" path="*.ogg" name="test" type="Namespace.Classname"/>
</handlers>
</system.webServer>
</configuration>
Hope this helps.
Cheers.

Resources