请找到我的客户代码
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}
运气好吗?
由于
萨拉