Hi All
I created two projects, an ASP.NET Core 7 Web API, and an ASP.NET Core 7 MVC project.
URL of my ASP.NET Core 7 Web API project is
localhost:7271
Now my question is how to configure this url in the ASP.NET Core 7 MVC project and call inside the controller. I am in learning stage. So please help me to resolve the issue.
In which place we have to write the API configuration in the ASP.NET Core 7 MVC project. Thanks!

ASP.NET Core 7 MVC project:

Amit MohantyPosted Oct 5, 2023, 5:47 AM
You can use RestClient to call API in your ASP.NET Core 7 MVC project.
GET Method:
POST Method:
Sneha KPosted Oct 5, 2023, 5:44 AM
Hi Sachin
i will check it and let you know
Sachin SinghPosted Oct 5, 2023, 5:31 AM
@Sneha, the process is still the same you can call your api using ajax or HttpClient or RestClient
You can create an extension method for resulability (Deserialize to Objects) and then use it
Then on Controller or any class library service project
Sneha KPosted Oct 5, 2023, 5:13 AM
Hi Thahir,
i configured the api url in app settings.json file now how i call inside controller . In old technology we will use Http client here in dot net 7 mvc project how i call this any sample code pls?
Tahir AnsariPosted Oct 5, 2023, 3:39 AM
You need to create api code first in asp.net core api project.
Then consume in asp.net core MVC and configure based address of your api in appsettings.json like this
{
"ApiSettings": {
"ApiBaseUrl": "http://localhost:7271"
},
// Other settings...
}
and call it in controller while consuming api