Reputation: 1020
I have created an app with angular area inside mvc, but routing seems to be an issue in it,
ny rout ts file has route as follows :
const routes: Routes = [
{
path: '',
redirectTo: '/Listing/Listings',
pathMatch: 'full',
},
{
path: 'Listing/Listings',
component: AppComponent
},
{
path: 'Listing/Listings/details', component: TableComponent, children: [
{ path: ':id', component: ListingComponent } // url: about/item
]
},
{
path: 'Listing/Listings/details/:id', component: ListingComponent,
},
];
and in my mvc controller i have details action
public ActionResult Details(int? id)
{
return View("index");
}
but when ever i try
http://localhost:9101/Listing/Listings/details or http://localhost:9101/Listing/Listings/details/1 in both cases it loads tablecomponent.
but i am expecting like http://localhost:9101/Listing/Listings/details = > should go to tablecomponent
and http://localhost:9101/Listing/Listings/details/1 => should go to listingcomponent.
why its going to tablecomponent always? how can i fix this?
Upvotes: 1
Views: 210
Reputation: 69
Add the below code to Route.config
routes.MapRoute(
name: "Angular",
url: "*"
);
Upvotes: 1