【问题标题】:Azure API Apps removing standard server headersAzure API 应用程序删除标准服务器标头
【发布时间】:2015-10-19 09:47:16
【问题描述】:

我有一个使用 API 应用程序部署到天蓝色的 ASP.net WebApi。要从最佳实践的神秘列表中检查另一个项目,我想从所有 HTTP 请求(x-powered-by、server、x-aspnet-version)中删除标准服务器标头。根据建议的配置,我的 web.config 在下面here

如果将我的应用程序部署到 Azure Web 应用程序,则会成功删除标头。但是,似乎对 Azure API APP 重复相同的部署不遵守执行此操作的标准 web.config 配置,并且所有 http 请求中仍然存在上述标头。

有谁知道这是否尚不支持,或者是否有其他方法可以做到这一点?我只能认为网关或其他设备不尊重删除。

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime enableVersionHeader="false"  />
  </system.web>
  <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <security>
      <requestFiltering removeServerHeader ="true"></requestFiltering>
    </security>
    <httpProtocol>
      <customHeaders>
        <clear />
        <remove name="X-Powered-By"/>
      </customHeaders>
    </httpProtocol>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

【问题讨论】:

    标签: azure asp.net-web-api azure-api-apps


    【解决方案1】:

    我们正在调查此问题并将其修复。同时,您可以转到网关的应用设置并修改其 web.config。步骤:

    1. 导航到 YOURGATEWAYNAME.scm.azurewebsites.net
    2. 导航到站点\wwwroot
    3. 滚动到 web.config 并单击左侧的编辑按钮。您将能够编辑此文件。

    或者,如果您不使用任何 API 应用程序的特定功能,您可以将您的 Web API 部署为 Web 应用程序。

    【讨论】:

    • 嗨@Mohit 我试了一下,将网关的 web.config 编辑为与上面通过 KUDO 发布的相同,但是通过 Fiddler 查看请求时仍然存在标准标头。我确实计划使用一些特定的 API 应用程序功能,因此如果可能的话,我会尝试让它与 API 应用程序而不是 Web 应用程序一起使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    • 2010-11-13
    • 1970-01-01
    • 2017-07-11
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多