部署到 Azure 时图形丢失
Graphics missing when deploying to azure
我刚刚将我的第一个 MVC5 应用程序部署到 Azure,一切正常,只是它不显示图形。在我的开发机器上这有效。
我的图形在文件夹 ~/Content/Graphics
中,这是 _Layout.cshtml
中引用一个
的部分
<img src="@Url.Content("~/content/graphics/EluciusSoft_Logo.svg")" style="height:50px">
不过,我知道这些文件在服务器上,因为我用 WebMatrix
检查过它。为什么他们不显示?
编辑:浏览器控制台错误消息如下:
Failed to load resource: the server responded with a status of 404
(Not Found)
这是使用 WebMatrix
.
的站点目录的屏幕截图
如果网络服务器尚未配置 SVG 的 MIME 类型,那么当您尝试访问它时,它将 return 出现 404 错误。您可以在应用程序的 web.config:
中定义 MIME 类型
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
我刚刚将我的第一个 MVC5 应用程序部署到 Azure,一切正常,只是它不显示图形。在我的开发机器上这有效。
我的图形在文件夹 ~/Content/Graphics
中,这是 _Layout.cshtml
中引用一个
<img src="@Url.Content("~/content/graphics/EluciusSoft_Logo.svg")" style="height:50px">
不过,我知道这些文件在服务器上,因为我用 WebMatrix
检查过它。为什么他们不显示?
编辑:浏览器控制台错误消息如下:
Failed to load resource: the server responded with a status of 404 (Not Found)
这是使用 WebMatrix
.
如果网络服务器尚未配置 SVG 的 MIME 类型,那么当您尝试访问它时,它将 return 出现 404 错误。您可以在应用程序的 web.config:
中定义 MIME 类型<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>