I have Two projects asp .net core Api and asp .net core MVC. In the asp .net core Api have a Two Replicas(instance) and asp .net core MVC have a three Replicas(instances).
So i want connect one pod of Api to one pod of MVC and than connect second pod of Api to second pod of MVC and than connect third pod of MVC to both pod of Api.
So i want when i Run the one pod of Api and MVC connected the Api data get and show in the MVC project.
So i want Pod’s url for get data from Api.
I trying to pass pod url (Base Url) like this below image but this url is not working in MVC
[HttpGet]
public async Task<ActionResult> GetMySqlData()
{
string Baseurl = "http://webapiservice-0.webapiservice.default.pod.cluster.local:8081/";
List<Customer> EmpInfo = new List<Customer>();
using (var client = new HttpClient())
{
//Passing service base url
client.BaseAddress = new Uri(Baseurl);
//Sending request to find web api REST service resource GetAllEmployees using HttpClient
HttpResponseMessage Res = await client.GetAsync("home/MySqlData");
//Checking the response is successful or not which is sent using HttpClient
if (Res.IsSuccessStatusCode)
{
//Storing the response details recieved from web api
var EmpResponse = Res.Content.ReadAsStringAsync().Result;
//Deserializing the response recieved from web api and storing into the Employee list
EmpInfo = JsonConvert.DeserializeObject<List<Customer>>(EmpResponse);
}
//returning the employee list to view
return View(EmpInfo);
}
}
I want to use with specific pod connection of Api and MVC to Get data through Api and show in MVC.