Asp.net Web API不响应响应
我正在使用ASP.NET核心中的WEB API。我得到了结果。但突然间我得到了一个例外 System.AggregateException:'值''无效。ameters=[{parameters}],CommandType='{commandT'' SocketException:远程主机强制关闭了现有连接。 IOException:无法从传输连接读取数据:远程主机强制关闭了现有连接。。 HttpRequestException:将内容复制到流时出错 这是我的密码Asp.net Web API不响应响应,asp.net,api,Asp.net,Api,我正在使用ASP.NET核心中的WEB API。我得到了结果。但突然间我得到了一个例外 System.AggregateException:'值''无效。ameters=[{parameters}],CommandType='{commandT'' SocketException:远程主机强制关闭了现有连接。 IOException:无法从传输连接读取数据:远程主机强制关闭了现有连接。。 HttpRequestException:将内容复制到流时出错 这是我的密码 {
{
string responseXML = string.Empty;
try
{
System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient { Timeout = new TimeSpan(0, 0, 500) };
var eP = "EndpointBAseURL" + url;
httpClient.BaseAddress = new Uri(eP);
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
System.Net.Http.StringContent content = new System.Net.Http.StringContent(requestData, System.Text.Encoding.UTF8, "application/json");
//Exception Happens in the following Line
System.Net.Http.HttpResponseMessage response = httpClient.PostAsync(eP,content).Result;
if (response.IsSuccessStatusCode)
{
responseXML = response.Content.ReadAsStringAsync().Result;
}
}
catch (WebException webEx)
{
responseXML = null;
WebResponse response = webEx.Response;
Stream stream = response.GetResponseStream();
String responseMessage = new StreamReader(stream).ReadToEnd();
//return responseMessage;
}
return responseXML;
}