asp.net - web.config 重写规则在 Blob 存储中的 Azure 静态网站中不起作用

标签 asp.net reactjs azure azure-storage

我有一个托管在 Azure blob 存储中的单页 React 应用程序,但在深度链接到页面时收到请求的内容不存在。错误:

enter image description here

我已在存储帐户中启用静态网站选项:

enter image description here

这些文件都位于 $web 容器中:

enter image description here

这包括以下web.config,其中包含一个重写规则,该规则应该让index.html处理所有路由:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="React Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

谁能看出我哪里出了问题吗?

最佳答案

如果您将 404 页面指向 index.html,则可以进行深层链接。这不是一个完美的解决方案 - 有副作用 - 但它适用于大多数情况。

enter image description here

关于asp.net - web.config 重写规则在 Blob 存储中的 Azure 静态网站中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55598531/

相关文章:

c# - 如何动态地将文本框中的数据绑定(bind)到 ListView 中

javascript - 是否可以在不使用 React 应用程序的情况下使用 React-Speech-Recognition?

javascript - 当我通过 fetch API 请求记录我的 React 状态 setState 时,为什么会收到两个响应?

azure - 是否可以使用美国政府租户在 'commercial' 公共(public) Azure 门户中注册的 Azure AD 应用程序?

c# - 将 Bot 框架与 LUIS 连接。我应该使用哪个 AppId 和 AppKey?

c# - 升级到 EL 5 'Microsoft.Practices.EnterpriseLibrary.Caching ..或其依赖项之一时出错

c# - 进行异步工作以返回快速响应的最佳方法

javascript - 将数据从 ASP Web 表单页面传递到 Angular2 应用程序

javascript - React Native Undefined 不是一个对象(评估'userData.id)

c# - 安装 SDK 1.8 后出现 WaHostBootstrapper 错误