0
我有一個使用angular2路由的ASP.NET CORE應用程序。按預期方式運行本地路由。當我發佈到服務器(運行IIS 7)時,這些路由似乎解析爲服務器根目錄,而不是它們部署到的網站,但它們仍呈現該頁面。在下面的示例中,「頁面url」是我導航到的頁面,但「瀏覽器地址欄」中顯示的是「結果url」。使用.NET Core的Angular2路由
page url --> http://myserver/myapp/home
result url --> http://myserver/home
有關爲什麼會發生這種情況的任何想法?這是一個IIS設置,或角度路由問題或.NET CORE配置問題?
這裏是我在angular2中配置路由的方式。
const routes: ClientRouterConfig = [
{ displayName: 'Dashboard', icon: 'fa fa-tachometer', path: '', redirectTo: 'home', pathMatch: 'full' },
{ showInNavigationMenu: true, displayName: 'Dashboard', icon: 'fa fa-tachometer', path: 'home', component: HomeComponent },
{ showInNavigationMenu: true, displayName: 'New Work Order', icon: 'fa fa-plus', path: 'workorder', component: WorkorderComponent },
{ showInNavigationMenu: false, displayName: 'Work Order', icon: 'fa fa-wrench', path: 'workorder/:id', component: WorkorderComponent },
{ showInNavigationMenu: false, displayName: 'New Task', icon: 'fa fa-user', path: 'task/create/:woid', component: TaskComponent },
{ showInNavigationMenu: false, displayName: 'Task', icon: 'fa fa-user', path: 'task/:id', component: TaskComponent },
{ displayName: 'Dashboard', icon: 'fa fa-tachometer', path: '**', redirectTo: 'home' } //this must be last
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
getRoutes() {
return routes;
}
}
你有沒有嘗試添加<基本href =「/ MyApp的/」索引文件的HTML – happyZZR1400
繁榮,這是它的頭部標籤內!非常感謝!如果您想將其作爲答案發布,我會將其標記爲正確 – hewstone