Añadir mapeo MIME en web.configuración para IIS Express


Necesito agregar una nueva asignación MIME para .extensiones de archivo woff para IIS Express.

Si agrego el siguiente fragmento al "applicationhost.config " de IIS Express funciona bien:

<staticContent lockAttributes="isDocFooterFileName">
    <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
    ...

Pero en realidad me gustaría añadirlo a mi "web.config" para que no todos los desarrolladores tengan que cambiar su " applicationhost.config " localmente.

Así que lo quité de nuevo del "applicationhost.config " y agregó el siguiente fragmento al proyecto "web.config":

<system.webServer>
  ...
  <staticContent>
    <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
  </staticContent>
</system.webServer>

Desafortunadamente no parece funcionar de esa manera porque cuando intento acceder a un .archivo woff Acabo con un error HTTP 404.3.

¿Qué estoy haciendo mal?

Author: hello_there_andy, 2012-01-26

8 answers

Poniéndolo en la "web.config" funciona bien. El problema era que me equivoqué con el tipo MIME. En lugar de font/x-woff o font/x-font-woff debe ser application/font-woff:

<system.webServer>
  ...
  <staticContent>
    <remove fileExtension=".woff" />
    <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
  </staticContent>
</system.webServer>

Vea también esta respuesta con respecto al tipo MIME: https://stackoverflow.com/a/5142316/135441

Actualización 4/10/2013

Especificación es ahora una recomendación y el tipo MIME es oficialmente: application/font-woff

 299
Author: Martin Buberl,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:02:34

Si alguien encuentra esto con errores como Error: no se puede agregar una entrada de colección duplicada de tipo 'mimeMap' con el atributo de clave única y / u otros scripts dejan de funcionar al hacer esta corrección, podría ayudar a eliminarlo primero de esta manera:

<staticContent>
  <remove fileExtension=".woff" />
  <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>

Al menos eso resolvió mi problema

 57
Author: Hawk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-28 17:27:17
<system.webServer>
     <staticContent>
      <remove fileExtension=".woff"/>
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
    </staticContent>
  </system.webServer>
 16
Author: Mohamed.Abdo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-04 08:14:32

Sé que esta es una vieja pregunta, pero...

Estaba notando que mi instancia de IISExpress no estaba sirviendo archivos woff, así que no busqué (Encontré esto) y luego encontré:

Http://www.tomasmcguinness.com/2011/07/06/adding-support-for-svg-to-iis-express /

Supongo que mi instalación tiene soporte para SVG ya que no he tenido problemas con eso. Pero las instrucciones son trivialmente modificables para woff:

  • Abra una aplicación de consola con el administrador privilegios.
  • Navegación al directorio IIS Express. Esto vive bajo Archivos de Programa o Archivos de programa (x86)
  • Ejecute el comando:

    Appcmd set config / section: staticContent /+[FileExtension= 'woff', mimeType='application/x-woff']

Resolvió mi problema, y no tuve que meterme con alguna configuración de mala calidad (como tuve que agregar soporte para los verbos PUT y DELETE). Yay!

 6
Author: JayC,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-03-21 03:06:01

Gracias por este post. Tengo esto trabajado para el uso de plantillas de bigote en mi asp.net proyecto mvc Usé lo siguiente, y funcionó para mí.

<system.webServer>   
  <staticContent>
   <mimeMap fileExtension=".mustache" mimeType="text/html"/>
  </staticContent>
</system.WebServer>
 3
Author: Daman Singh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-02-27 09:40:30

No estoy usando IIS Express sino desarrollándome contra mi IIS 7 Completo local.

Así que si alguien más get está aquí tratando de hacer eso, tuve que agregar el tipo mime para woff via IIS Manager

Tipos Mime > > Haga clic en Agregar enlace a la derecha y luego ingrese Extensión: .woff Tipo MIME: application / font-woff

 3
Author: Nathan Prather,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-02 21:44:35

Para resolver el problema, haga doble clic en la opción de configuración "Tipos MIME" mientras tiene seleccionado el nodo raíz de IIS en el panel izquierdo y haga clic en "Agregar..."enlace en el panel de Acciones a la derecha. Esto abrirá el siguiente diálogo. Añadir .extensión de archivo woff y especificar "application / x-font-woff"como el tipo MIME correspondiente:

introduzca la descripción de la imagen aquí

Siga lo mismo para woff2 con application / x-font-woff2

 2
Author: Tarun Gupta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-03 08:20:59

Estaba teniendo un problema para conseguir mi ASP.NET 5.0 / MVC 6 aplicación para servir tipos de archivos binarios estáticos o navegar por directorios virtuales. Parece que esto se hace ahora en Configure () al inicio. Véase http://docs.asp.net/en/latest/fundamentals/static-files.html para una imprimación rápida.

 0
Author: Brian Wirt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-05 22:22:08