I have created an out of the box ASP.NET Core 6 Web API project.
When I launch the project I can see Swagger loaded, displaying a single WeatherForecast endpoint which works when tested.
However, when I launch the Web API project from another .NET Core app, the controllers are not discovered. Swagger returns the following message for reference. Also manually calling the endpoint Url fails.
After some investigation into this issue, I found that if I register the WeatherForecast controller manually it will become visible in Swagger and accessible when requested.
Why is the WeatherForecast controller not being discovered when running the ASP.NET app from another .NET Core App ?
Source Code: GitHub
2
Answers
Have you tried this:
Using the answer linked to by @RichardDeeming I was able to get it to work in .Net 6. Find
AddControllers
in Program.cs and adapt it to look like this (substituteTestServiceController
for one of your controllers that is in the target assembly):