WebAPI Core routing issues
Controllers can't have actions with the same Route Name
. They must be unique so that the route table can differentiate them.
Reference Routing to Controller Actions : Route Name
Route names can be used to generate a URL based on a specific route. Route names have no impact on the URL matching behavior of routing and are only used for URL generation. Route names must be unique application-wide.
emphasis mine
Update route names
[Route("api/teacher")]
public class TeacherController : Controller {
// GET: api/Teacher/5
[HttpGet("{id}", Name = "GetTeacher")]
public IActionResult Get(int id) {
//...
}
}
[Route("api/school")]
public class SchoolController : Controller
{
// GET: api/school/5
[HttpGet("{id}", Name = "GetSchool")]
public IActionResult Get(int id) {
//...
}
}
Removing the name on get action from both controllers will solve the problem