-1

I have a Web Api in Asp.Net Core 6 which calls another Web Api project in the same solution.

I have in my test:

FirstFactory<Program> firstFactory = new FirstFactory<Program>();
var firstClient = firstFactory.CreateClient();

SecondFactory<AnotherProject.Program> firstFactory = new SecondFactory<AnotherProject.Program>(); 

secondFactory.Server.BaseAddress = new Uri("https://localhost:7000");

var response = firstFactory.GetAsync("WeatherForecast");

It calls the first endpoint and when it gets to the second one, I get an exception: "No connection could be made because the target machine actively refused it".

What is causing this issue and how can it be solved?

MiBuena
  • 91
  • 8
  • There is some questions about this topic: https://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it. – Arcord May 27 '22 at 21:20
  • First thing to check: Put a debug and check if the application is actually running and if your machine is listening on the port 7000. – Arcord May 27 '22 at 21:21
  • @arcord, how do I check that the second project is running? We are in a unit test. – MiBuena May 28 '22 at 06:54
  • call `https://localhost:7000` directly in the browser? – Tiny Wang May 30 '22 at 03:06

0 Answers0