38

我正在使用带有 Update 2 和 IIS Express 的 Visual Studio 2012。

当我向 staticContent 部分添加记录时,所有其他静态内容(.js、.css、.jpg 等)都会返回 500 错误。

任何建议将不胜感激。提前致谢。

4

3 回答 3

92

mimetype 可能已经添加到您的 IIS 中。

尝试先删除 mimetype,然后在 web.config 中再次添加它

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

祝你好运!

于 2013-06-19T11:32:17.930 回答
1

Behavior of system.webServer/staticContent/mimeMap element has changed in IIS 7.0 and apparently one has to list all types explicitly to have them returned properly.

Here is a description from IIS configuration documentation:

Note: IIS 7 will not return file types that are not added to the element or that have mappings in the element by default. This behavior prevents unauthorized access to files that do not have mappings in the IIS 7 configuration settings.

于 2014-12-11T09:01:11.523 回答
0

如果您在 Visual Studio 中使用 IIS Express,则无需定义staticContent,因此将其删除。

默认情况下,Visual Studio IIS Express 允许所有 MIME 类型。

于 2015-10-19T08:12:45.737 回答