Angular 5 应用程序抛出 HTTP 错误 404.0 - 在 IdengtityServer 4 授权后未找到
Angular 5 App throws HTTP Error 404.0 - Not Found after being authorized by IdengtityServer 4
我有 Angular 5 应用程序(纯 html-ts 应用程序)重定向到 IdentityServer 4 MVC 站点进行登录。成功登录后,页面将重定向回 angular 应用程序索引页面,在 URL 中包含 id_token。索引页有仪表板视图。
当我在 VS Code 上 运行 时,本地一切正常。
仅在部署到 IIS 时出现问题。成功登录后,它返回到索引页面但抛出
HTTP 错误 404.0 - 未找到
您要查找的资源已被删除、更名或暂时不可用。
我已经尝试在 IIS 中设置 baseurl、maxQueryStringValue 以及我在 Internet 上可以找到的所有内容。这只是不想工作:(
过去 2 天一直在尝试修复此问题,但没有成功。
要在 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>
希望对您有所帮助。
我有 Angular 5 应用程序(纯 html-ts 应用程序)重定向到 IdentityServer 4 MVC 站点进行登录。成功登录后,页面将重定向回 angular 应用程序索引页面,在 URL 中包含 id_token。索引页有仪表板视图。
当我在 VS Code 上 运行 时,本地一切正常。
仅在部署到 IIS 时出现问题。成功登录后,它返回到索引页面但抛出 HTTP 错误 404.0 - 未找到 您要查找的资源已被删除、更名或暂时不可用。
我已经尝试在 IIS 中设置 baseurl、maxQueryStringValue 以及我在 Internet 上可以找到的所有内容。这只是不想工作:(
过去 2 天一直在尝试修复此问题,但没有成功。
要在 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>
希望对您有所帮助。