how to call asp.net core web api in another asp.net(web form) project.
Loading
how to call asp.net core web api in another asp.net(web form) project.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal YelvePosted Sep 20, 2022, 1:39 PM
Please refer below link
https://www.c-sharpcorner.com/blogs/how-to-call-web-api-in-another-project-from-c-sharp
Naresh BeniwalPosted Oct 31, 2022, 4:28 AM
https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms
Sachin SinghPosted Sep 20, 2022, 5:34 PM
calling API from one project (Localhost:1234 or Domain A) to another project (localhost:3456 or DomainB) violates the CORS policy, so first step should be to enable CORS in your API project.
After enabling the CORS you can use HttpClient or RestClient or Jquery Ajax to consume the API from any project.
This is how you can consume API from web forms
To enable CORS in ASP.NET Core API
Amit MohantyPosted Sep 20, 2022, 12:34 PM
You can use RestSharp which is an open-source HTTP Client library that we can use to consume APIs.
For more details plese check the below articles
https://stackoverflow.com/questions/10226089/restsharp-simple-complete-example
https://code-maze.com/aspnetcore-using-restsharp-consume-api/