I have two projects ion a single solution, a .NET Core 7 API App and a Client side Blazor app which communicates with the API App.
I am developing this in Visual Studio, and have set the startup project as the Client Side project so that the blazor app loads in my web browser when I run the project.
The solution is setup to build and run the API app along with the client side project.
When I run the solution, the API runs on http://localhost:4000 however, attempt to call the API result in 405 Method not Allowed. The same result happens via Postman.
If I now switch the startup project to the API rather than the blazor client app – I can no longer use the blazor app, however I can still test the API in Postman on the same address and the API will now work.
In API app, I have also added the following to the Program.cs file:
app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
I cannot figure out what could be wrong with my project setup, any pointers would be appreciated.
>Solution :
You need to run both API and Client side app.
Right click on Solution -> Properties → Common Properties → Startup Project and select Multiple startup projects.
