I have one asp.net web api (app1) which is running with localhost in my machine,
https://localhost:44301/weatherforecast
Other asp.net web api (app2) which I hosted over azure app service,
https://webapiapp120200626111110.azurewebsites.net/weatherforecast
calling app1's apihttps://localhost:44301/weatherforecast
[HttpGet] public async Task<string> Get() { var result = string.Empty; using var client = new HttpClient(); var defaultRequestHeaders = client.DefaultRequestHeaders; if (defaultRequestHeaders.Accept == null || defaultRequestHeaders.Accept.All(m => m.MediaType != "application/json")) { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } var response = await client.GetAsync("https://localhost:44301/weatherforecast"); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsStringAsync(); } return result; }
Here I am getting 500
error if I host app2
as azure app service, if I run it locally over localhost
, then NO issues.
Is this something block on localhost, how we can do this?