David Lindon
David Lindon

Reputation: 355

Routing in an ASP.NET Core app with Angular

I have created a project using the template in visual studio as below -

enter image description here

This has created the 'WeatherForecast' controller with a simple get method. I would like to add additional methods to this controller as a test but when accessing this methods, the Angular homepage is returned. As a test I have navigated to the urls in a browser and correctly see the json returned for /get but the Angular homepage is returned for /MyTeam. I imagine there is a simple configuration I've missed somewhere but after hours of searching I'm stuck.

enter image description here

JSON returned correctly for get method

enter image description here

I'm expecting to see the same JSON returned here

enter image description here

Question - how can I expose additional methods in the controller?

Upvotes: 0

Views: 52

Answers (1)

Sahil Patel
Sahil Patel

Reputation: 26

It looks like both the methods have the same default route

[Route("")]

Try changing the route for the other get methods. You can either decorate the method using:

[HttpGet("team")] 

or

[HttpGet]
[Route("myteam)] 

Upvotes: 1

Related Questions