Angular 如何防止默认路由重定向到"#/&引用;?

Angular 如何防止默认路由重定向到"#/&引用;?,angular,angular2-routing,Angular,Angular2 Routing,当我访问http://localhost/它将我重定向到http://localhost/#/。是否有可能防止这种情况并保持在http://localhost/并在请求root时加载默认组件?我需要使用HashLocationStrategy,因为我还在同一个项目中使用ASP.NET核心MVC及其路由 export const HomeRoutes = [ { path: '', component: HomeComponent }, { path: 'Home', compon

当我访问
http://localhost/
它将我重定向到
http://localhost/#/
。是否有可能防止这种情况并保持在
http://localhost/
并在请求root时加载默认组件?我需要使用
HashLocationStrategy
,因为我还在同一个项目中使用ASP.NET核心MVC及其路由

export const HomeRoutes = [
    { path: '', component: HomeComponent },
    { path: 'Home', component: HomeComponent },
];

const MyRoutes: Routes = [
    ...HomeRoutes
];

export const MyRouting = RouterModule.forRoot(MyRoutes, { useHash: true });

您正在使用哈希策略更改此行的导出语句

export const MyRouting = RouterModule.forRoot(MyRoutes, { useHash: false });

您正在使用哈希策略更改此行的导出语句

export const MyRouting = RouterModule.forRoot(MyRoutes, { useHash: false });

抱歉,忘记添加我需要使用HashLocationStrategy,因为我在同一项目中也使用ASP.NET Core MVC。抱歉,忘记添加我需要使用HashLocationStrategy,因为我在同一项目中也使用ASP.NET Core MVC。