我想在Angular中将我的应用程序部署到 生产环境 服务器,但我遇到了问题 . 当我只使用角度路由(更改组件,而不是重定向)时,应用程序可以正常运行,但是当我在浏览器中刷新页面时,我从IIS返回一个404页面(我使用IIS作为Web服务器)
这是我的角度路由:
const appRoutes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full', canActivate: [AuthGuard] },
{ path: 'home', component: DashboardComponent, canActivate: [AuthGuard] },
{ path: "profile", component: UserProfileComponent, canActivate: [AuthGuard] },
{ path: '400', component: ErrorComponent },
{ path: '401', component: ErrorComponent },
{ path: '403', component: ErrorComponent },
{ path: '404', component: ErrorComponent },
{ path: '500', component: ErrorComponent },
{ path: '503', component: ErrorComponent },
{ path: '**', redirectTo: '/404' }
]
1 回答
我在我的应用程序中修改了web.config:
在index.html中是
<base href="./">
. 刷新页面现在可以了 .