首页 > 解决方案 > web.config 中的位置 + 路径在 Azure 中不起作用

问题描述

刚刚创建了一个新的 Asp.Net Core MVC 应用程序并将其发布到 Azure。

通过将位置/路径元素添加到 web.config 并重新发布站点....我的 azure-app 立即损坏。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="authenticate" allowOverride="true">
    <system.webServer>
      <security>
        <access sslFlags="SslNegotiateCert" />
      </security>
    </system.webServer>
  </location>
</configuration>

为什么以下内容在 Azure Web App 中不起作用?

标签: azureasp.net-core

解决方案


假设您想限制用户访问身份验证文件夹下的任何内容,您能否尝试以下代码:-

以下 web.config 示例将元素中的任何设置仅应用于位于站点 /authenticate 目录中的任何资源:

 <location path="~/authenticate" allowOverride="true">
    <system.webServer>
      <security>
        <access sslFlags="SslNegotiateCert" />
      </security>
    </system.webServer>
  </location>

如果它不起作用,您能否启用下 system.web 并让我知道您遇到了什么错误。


推荐阅读