【问题标题】:Azure and .json mimeType without web.config没有 web.config 的 Azure 和 .json mimeType
【发布时间】:2012-09-13 01:33:34
【问题描述】:

添加到我的 web.config

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
</system.webServer>

允许我的应用程序在 Azure 上运行,但会导致我的远程 IIS 服务器崩溃,因为它已经包含在内。在这种特殊情况下,删除远程 IIS mimeType 是不切实际的。我最终使用了不同的 web.config

是否有另一种机制可以让我配置 Azure IIS mimeType,这样我就没有这个有问题的 web.config?

我想要一个可以在 Azure 和非 Azure 上运行的部署包。

【问题讨论】:

  • 两个想法:web.config 转换,但这意味着不同的部署配置文件或 Azure 中对 web.config 进行必要调整的启动任务。

标签: azure web-config


【解决方案1】:

这应该可行:

<system.webServer>
  <staticContent>
    <remove fileExtension=".json" />
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
</system.webServer>

参见此处:http://blogs.msdn.com/b/chaun/archive/2009/12/04/iis7-error-cannot-add-duplicate-collection-entry-of-type-mimemap-with-unique-key-attribute-fileextension.aspx

这对您的整体 IIS 配置没有任何影响,它只是有条件地从该特定站点的配置中删除 mimeMap(受此 web.config 管理),然后再次添加它。

【讨论】:

    【解决方案2】:

    您可以create a startup task 在 IIS 级别添加 mime 类型。这样您就不需要将它包含在您的 web.config 中:

    "%windir%\System32\inetsrv\appcmd.exe" set config /section:staticContent /+"[fileExtension='.json',mimeType='application/json']"
    exit /b 0
    

    【讨论】:

      猜你喜欢
      • 2020-03-01
      • 1970-01-01
      • 2016-09-19
      • 2014-02-10
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2018-01-23
      • 1970-01-01
      相关资源
      最近更新 更多