为Windows Azure Web站点添加MIME类型解决文件下载失败的问题

简介:


这几天在倒腾Autodesk 360 Viewer,前面的文章也介绍过了,这将是一个全新的在线模型浏览工具。我做了个实验,把A360Viewer放在一个web 站点,然后发布到Windows Azure上去。目前A360 Viewer的模型是*。svf文件,可站点发布成功后,奇怪的事情发生了。通过Chrome浏览站点,页面文字图片显示均正常,唯独模型迟迟不加载。后来通过Chrome的开发者工具条(按F12)一看,原来所有的*.svf即模型文件都返回HTTP 404 file not found错误。这怎么可能呢?模型文件我明明已经上传到web服务器了啊,怎么会找不到呢?对了,我是用Chrome的开发者工具中 的network 选项卡发现*.svf文件没有下载成功的,其他浏览页有类似的工具:

image

后来想到,http 404可能不是仅仅是文件不存在,权限错误、MIME类似错误等也会引起这个问题,对于*.svf这样比较少见的扩展名,一般的web服务不认识也情有可原,不认识就不知道怎么处理,所以返回404错误。解决的办法就是为他加上MIME类型。在本地IIS管理服务器中我们可以这么操作(如图):

image image

不过我现在使用的是Windows Azure的web站点,不能访问到IIS管理器了,那怎么办呢?放Google搜索了一下,这个链接this link 给出了正确的方法,即修改web.config文件,把自定义的MIME类型加入到web.config文件中:

 

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.0" />
    </system.web>
 
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".svf" mimeType="vector/vnd.svf" />
      <mimeMap fileExtension=".pack" mimeType="vector/vnd.svf" />
    </staticContent>
  </system.webServer>

 
</configuration>

 

重新发布后,一切都OK了。大多数时候错误信息能帮你定位问题所在,不过也有时候错误信息会和你开个小玩笑 ;)

作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。




本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/p/3608127.html ,如需转载请自行联系原作者
相关文章
|
24天前
|
Linux C++ Windows
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
|
24天前
【Azure 应用服务】Web App Service 中的 应用程序配置(Application Setting) 怎么获取key vault中的值
【Azure 应用服务】Web App Service 中的 应用程序配置(Application Setting) 怎么获取key vault中的值
|
24天前
【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term 'Select-AzContext' is not recognized as the name
【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term 'Select-AzContext' is not recognized as the name
|
24天前
|
PHP Windows
【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误
【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误
|
17天前
|
UED
JSF文件下载:解锁终极文件传输秘籍,让你的Web应用瞬间高大上!
【8月更文挑战第31天】掌握JSF文件下载功能对构建全面的Web应用至关重要。本文通过具体代码示例,详细介绍如何在JSF中实现文件下载。关键在于后端Bean中的文件读取与响应设置。示例展示了从创建实体类到使用`&lt;h:commandLink&gt;`触发下载的全过程,并通过正确设置响应头和处理文件流,确保文件能被顺利下载。这将显著提升Web应用的实用性与用户体验。
31 0
|
17天前
|
开发者 iOS开发 C#
Uno Platform 入门超详细指南:从零开始教你打造兼容 Web、Windows、iOS 和 Android 的跨平台应用,轻松掌握 XAML 与 C# 开发技巧,快速上手示例代码助你迈出第一步
【8月更文挑战第31天】Uno Platform 是一个基于 Microsoft .NET 的开源框架,支持使用 C# 和 XAML 构建跨平台应用,适用于 Web(WebAssembly)、Windows、Linux、macOS、iOS 和 Android。它允许开发者共享几乎全部的业务逻辑和 UI 代码,同时保持原生性能。选择 Uno Platform 可以统一开发体验,减少代码重复,降低开发成本。安装时需先配置好 Visual Studio 或 Visual Studio for Mac,并通过 NuGet 或官网下载工具包。
24 0
|
24天前
|
网络安全 API 数据安全/隐私保护
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
|
24天前
|
Shell PHP Windows
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
|
24天前
|
应用服务中间件 nginx Windows
【Azure 应用服务】在App Service for Windows中实现反向代理
【Azure 应用服务】在App Service for Windows中实现反向代理