【问题标题】:Angular 5 App throws HTTP Error 404.0 - Not Found after being authorized by IdengtityServer 4Angular 5 应用程序抛出 HTTP 错误 404.0 - 经 IdengtityServer 4 授权后未找到
【发布时间】:2019-01-09 19:50:45
【问题描述】:

我有 Angular 5 应用程序(纯 html-ts 应用程序),它重定向到 IdentityServer 4 MVC 站点进行登录。成功登录后,页面将被重定向回 URL 中带有 id_token 的 Angular 应用索引页面。索引页面具有仪表板视图。

当我在 VS Code 上运行时,一切都在本地运行良好。

仅在部署到 IIS 时才会出现问题。成功登录后,它返回到索引页面但抛出 HTTP 错误 404.0 - 未找到 您要查找的资源已被删除、名称已更改或暂时不可用。

我尝试在 IIS 中设置 baseurl、maxQueryStringValue 以及我在 Internet 上可以找到的所有内容。这只是不想工作:(

过去 2 天一直在尝试解决此问题,但没有成功。

【问题讨论】:

  • 你是否在 IIS 中使用 URL 重写规则在 Angular 中进行路由?
  • 我读过它,但我应该检查什么规则并将其重写为@dheeraj?

标签: angular iis http-status-code-404 identityserver4


【解决方案1】:

要使路由在 IIS 上的 Angular 应用程序中工作,您需要在 Web.config 中添加以下内容。

在应用程序文件夹中创建一个 Web.config 文件。 在 Web.config 中添加如下

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="AngularJS 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="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

希望这会有所帮助。

【讨论】:

  • 太棒了。这样可行。我实际上之前尝试过,但由于缺少 IIS Rewrite 扩展而在 IIS 中出现配置错误。这次我首先通过安装 IIS Rewrite ext 解决了这个问题。现在一切都很好。谢谢!
  • 乐于助人:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-07
  • 1970-01-01
  • 2015-01-16
相关资源
最近更新 更多