I am in the process of creating an Angular 2 application.
After starting the project in Visual Studio 2017, I managed to successfully route to the app within an Area (Home2017/Start/Index.cshtml):
Route toHome2017 = null;
toHome2017 = routes.MapRoute(
name: "Default_to_Home2017",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Start", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "BIP2.Areas.Home2017.Controllers" }
);
toHome2017.DataTokens["area"] = "Home2017";
The Angular routing setup is as follows:
RouterModule.forRoot([
{
path: 'Architecture',
component: ArchitectureComponent,
pathMatch: 'full'
},
{
path: '',
component: StartpageComponent,
pathMatch: 'full'
}
])
]
When I navigate to /Architecture, the Angular routing works correctly.
However, when I refresh the page and redirect it to Home2017/Start/Index using:
toHome2017 = routes.MapRoute(
name: "Default_to_Architecture",
url: "Architecture",
defaults: new { controller = "Start", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "BIP2.Areas.Home2017.Controllers" }
);
toHome2017.DataTokens["area"] = "Home2017";
The application loads, but the Angular path: '' with the StartpageComponent is displayed with the URL /Architecture/.
What could be causing this issue?
UPDATE: This method worked for me previously with AngularJS