c# - 不调试时无法通过路由访问组件
问题描述
我目前正在开发一个带有 Dot Net Core API 后端的 Angular 单页应用程序,并且在我的应用程序中遇到了路由问题。
在我的 Angular 应用程序中使用“ng-serve”并使用 localhost:4200 访问 SPA 时,我可以访问我的密码重置路由并显示组件。但是,当我运行“ng-build”以在我的 Dot Net Core API 中创建 wwwroot 文件夹并尝试通过地址栏访问路由时,它说在 localhost:38611 或 localhost:44316 中都找不到该页面(SSL )。
我的导航路线的代码如下
export const routes: Routes = [
{ path: 'password-reset', component: UserPasswordResetComponent },
{ path: '', component: HomeComponent },
{
path: '',
runGuardsAndResolvers: 'always',
canActivate: [AuthenticateGuard],
children: [
{ path: 'downloads', component: MenuDownloadsComponent },
{ path: 'user-profile', component: UserProfileComponent }
]
},
{
path: '',
runGuardsAndResolvers: 'always',
canActivate: [ManagerGuard],
children: [
{ path: 'manager-dashboard', component: DashboardManagerComponent },
{ path: 'history', component: MenuHistoryComponent }
]
},
{
path: '',
runGuardsAndResolvers: 'always',
canActivate: [AdminGuard],
children: [
{ path: 'admin-dashboard', component: DashboardAdminComponent },
{ path: 'user-admin', component: MenuAdminUserComponent },
{ path: 'company-admin', component: MenuAdminCompanyComponent },
{ path: 'software-admin', component: MenuAdminSoftwareComponent },
{ path: 'release-admin', component: MenuAdminReleaseComponent },
{ path: 'item-admin', component: MenuAdminItemComponent },
{ path: 'uploads', component: MenuUploadsComponent }
]
},
{ path: '**', redirectTo: '', pathMatch: 'full' }
];
我很困惑为什么它在一个实例中起作用但在其他实例中不起作用,任何帮助将不胜感激。
我将 VS Code 用于我的 Angular(我最近更新到 Angular 10)和 Visual Studio 用于 Dot Net Core(版本 3.1),但我也尝试在 VS Code 中运行它,但无济于事。
解决方案
推荐阅读
- uipath - 如何从 Studio 中的 UiPath QueueItem 中提取数据值?
- python - SQL alchemy 日期时间格式而不是 YYYY/MM/DD,希望是 DD/MM/YYYY
- branch.io - 将分支链接用于广告活动时,是否有必要将 SKAdNetwork 集成到 iOS 14 上的自己的应用程序中?
- django - Django:我如何查询帖子以显示给用户?
- reactjs - React:自定义 Ref(没有 DOM)
- c++ - 如何使用 c++ win32 api 更改应用程序中不是我的菜单项的控件的标题?
- java - Maven 依赖不可用 | 存在于本地 .m2 存储库中 | 使用 Eclipse 构建
- firebase - 两个 Web 应用程序 - 一个 firebase 项目:我应该为一个应用程序创建两个应用程序还是两个托管站点?
- python - 如何在python中分离一些重叠的时间段?
- json - 如何让 Swift 派生指定类型来解码 JSON