Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

405 Method now allowed when calling API project in multi project solution

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 -> PropertiesCommon PropertiesStartup Project and select Multiple startup projects.

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading