I was create simple project with .netCore 2.0
and send HttpRequest
with HttpClient
, that is working well.
But, when I'm migrating from .netCore 2.0
to upper version ( e.g: .NetCore 2.1
or .netCore 3.0
) this Code is not working.
My Code is:
public async Task<bool> IsValid()
{
string url = "http://api.domain.com/...";
var values = new Dictionary<string, string>()
{
{ "param1", "value1" },
{ "param2", "value2" }
};
HttpClient client = new HttpClient();
var content = new FormUrlEncodedContent(values);
var post = await client.PostAsync(url, content);
if (post.StatusCode == System.Net.HttpStatusCode.OK)
{
return true;
}
return false;
}
I expect the output of httpResponse
to bo HttpStatusCode.OK
. but the actual output is HttpStatusCode.GatewayTimeout
.
I found that:
If I run API server
( http://api.domain.com/
) in IIS
of windows server 2012
, all requests is working well.
But When I Use IIS
of Windows 8
, only HttpRequest
with ASP.NET Core sdk 2.0
is working and others not working.
Can anyone help me?