REST - HttpClient - Server, C#, http all ok, https not ok
Markus Freitag
3,786
Reputation points
@Lan Huang-MSFT,
Sorry, I can't reproduce your issue. Maybe you could follow SurferOnWww's advice: use Fiddler or equivalent to see what's going on between client and server.
I have found the cause, it is because of the security.
What can be the solution?
It would be great if I could get the server on another PC.
See my link. Do you know a good way, instruction.
How do you solve the authentication? What are the options?
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:55893/");
//client.DefaultRequestHeaders.Accept.Clear();
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//string authorization = $"{""}:{""}";
//client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "");
//GET Method
//HttpResponseMessage response = await client.GetAsync("api/valuesGET");
//http://localhost:55893/Api/ValuesGET
//string urlParameters = $@"Api/ValuesGET";
//urlParameters = $@"Api/ValuesGET?status=2";
//http://localhost:55892/api/ValuesGET?status=2
HttpResponseMessage response = client.GetAsync("Api/valuesGET").Result;
HttpResponseMessage response2 = await client.GetAsync("Api/valuesGET");
if (response.IsSuccessStatusCode)