请求已中止:当iis有子根时,连接意外关闭

时间:2018-06-11 11:43:35

标签: c# iis asp.net-web-api httpclient

请找到我的客户代码

HttpContent content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
HttpClient client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
string serverNameOne= "http://servername/wespapi/api/task/GetGanttTasks";
string ServerName= "http://servername/api/task/GetGanttTasks";
var response = client.PostAsync(durl1,content).Result;
return response.Content.ReadAsStringAsync().Result;

这是我调用web api的客户端代码。所有其他方法都可以正常使用serverNameOne地址。只有在这里我有一个问题。当我使用没有子根的ServerName时它工作正常。

异常详情:

 InnerException {"Error while copying content to a stream."} System.Exception {System.Net.Http.HttpRequestException}

内部异常

InnerException {"The request was aborted: The connection was closed unexpectedly."} System.Exception {System.Net.WebException}

运气好吗?

由于

萨拉

0 个答案:

没有答案