ASP.NET MVC 5在Azure上:"你正在寻找已被删除的资源..."为SVG文件 [英] ASP.NET MVC 5 on Azure: "The resource you are looking for has been removed..." for SVG files

查看:372
本文介绍了ASP.NET MVC 5在Azure上:"你正在寻找已被删除的资源..."为SVG文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个MVC 5网页一些视图和控制器,增加了一些图像(GIF和SVG),并验证了它的大部分工作在本地。图像显示,一切都按预期运行。

I have created an MVC 5 web page with some views and controllers, added some images (gif and svg), and verified that it's mostly working locally. The images show up and everything behaves as expected.

当我部署到Azure中,GIF图像加载罚款,但SVG图像给我的错误您正在寻找已被删除的资源,已更名或暂时不可用。当我登录到我的网站的FTP和我的Azure凭据时,GIF和SVG文件都在那里。我可以访问网络我的 /img/loading.gif 文件就好了;然而, /img/logo.svg - 虽然它的存在于目录和显示了,当我本地运行。 - 不是由我的Azure服务的网站找到

When I deploy to Azure, the gif image loads fine, but the svg images give me the error The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. When I log into my website's FTP with my Azure credentials, the gif and svg files are all there. I can access my /img/loading.gif file from the web just fine; however, /img/logo.svg -- while it does exist in the directory and does show up when I run locally -- is not found when served by my Azure website.

我不认为这是相关的,但我告诉我的网站现有路由文件:

I don't think it's relevant, but I am telling my website to route existing files:

routes.RouteExistingFiles = true;

和所有我的图片 - GIF和SVG - 位于解决方案mySolutionName' - > myMvcProjectName - > IMG 。所以,有什么我可以看到指示我的网站,以不同的方式对待这些文件。

And all my images -- gif and svg -- are located in Solution 'mySolutionName' -> myMvcProjectName -> img. So there's nothing I can see that instructs my website to treat these files differently.

推荐答案

原来,这与 staticContent MIME类型的问题,如在的this回答问题

Turns out this is a problem with staticContent MIME types, as in this answered question.

要解决,我发现我的< system.webServer>我的Web.config 部分:

To fix, I found my <system.webServer> section of my Web.config:

   <system.webServer>
     <modules>
       <remove name="FormsAuthentication" />
     </modules>
   </system.webServer>

和加入了&LT; staticContent&GT; 使用其适当的MIME类型映射SVG:

And added a <staticContent> mapping for SVG using its appropriate MIME type:

   <system.webServer>
     <modules>
       <remove name="FormsAuthentication" />
     </modules>
     <staticContent>
       <mimeMap fileExtension="svg" mimeType="image/svg+xml" />
     </staticContent>
   </system.webServer>

这篇关于ASP.NET MVC 5在Azure上:&QUOT;你正在寻找已被删除的资源...&QUOT;为SVG文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆