asp.net-mvc - Azure 上的 ASP.NET MVC 5 : "The resource you are looking for has been removed..." for SVG files

标签 asp.net-mvc azure svg

我创建了一个包含一些 View 和 Controller 的 MVC 5 网页,添加了一些图像(gif 和 svg),并验证它主要在本地工作。图像显示出来,一切都按预期运行。

当我部署到 Azure 时,gif 图像加载正常,但 svg 图像给我错误您正在查找的资源已被删除、名称已更改或暂时不可用。当我使用 Azure 凭据登录网站的 FTP 时,gif 和 svg 文件都在那里。我可以从网络访问我的 /img/loading.gif 文件;但是,/img/logo.svg - 虽然它确实存在于目录中并且确实在我本地运行时显示 - 在我的 Azure 网站提供服务时找不到

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

routes.RouteExistingFiles = true;

我的所有图像(gif 和 svg)均位于 Solution 'mySolutionName' -> myMvcProjectName -> img 中。因此,我看不到任何内容指示我的网站以不同方式处理这些文件。

最佳答案

事实证明这是 staticContent 的问题MIME 类型,如 this answered question .

为了解决这个问题,我找到了我的 <system.webServer>我的部分Web.config :

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

并添加了<staticContent>使用适当的 MIME 类型映射 SVG:

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

关于asp.net-mvc - Azure 上的 ASP.NET MVC 5 : "The resource you are looking for has been removed..." for SVG files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26516356/

相关文章:

c# - FluentValidation、Validators 生命周期和使用 Validators 检查 Db

c# - Html.Partial 搜索 aspx 而不是 cshtml

json - 在模式推断解析 json 中检测到格式错误的记录

javascript - 使用 d3js 将图像放置在网格中

asp.net-mvc - .NET MVC-从另一个 Controller Action 调用一个 Controller Action

c# - 为什么会在运行时陷入困境?

azure - 从 TFS 发布到 Azure 时,为什么我会收到 CouldnotfetchaccesstokenforAzureStatusCode

javascript - Microsoft Bot 自动测试

svg - 使用 SASS 从文件内联 SVG

javascript - HTML5 - SVG 元素在 Firefox 和 Chrome 上表现不同