Reputation: 1666
Let’s say I want route to a url as localist:8888/apps/my page
So this route should be set in angular components or .net mvc controller? Or both places.
My situation is I have a controller load all initial data already.do I create a new controller for this specific route?
Upvotes: 0
Views: 158
Reputation: 2059
Is that URL supposed to be exposed in your API or to render a page in the frontend?
If you want to expose this route in your API, you would need a new Controller for this. Then you could consume it in your Angular app making a request to that URL with the HttpRequest Action needed (GET, POST, PUT, etc...).
If you want to render some content in that url with your Angular app, then you would need to set the specific route to perform this action and refer to a component. (https://angular.io/start/routing).
Hope it helps!
Upvotes: 1
Reputation: 1481
The first time you navigate to your application, WebAPI will serve an html page + return the angular application to your browser. As soon as you receive the angular source, the navigation is handled by angular client-side. That means you do not emit any request to your WebAPI and therefore won't reach any controller.
The only routes you should create in your Controller are the one you want to request (with HttpClient
for example, post/get/...).
Upvotes: 0
Reputation: 530
Yes, you need to create the controller and view called mypage then create a component and render into .cshtml page.
Then you can access your page which you need to access # localhost:8888/apps/mypage
Upvotes: 0