2017-06-30 173 views
-1

这里访问本地IIS是错误,我得到:无法从远程桌面

System.AggregateException: One or more errors occurred. 
---> System.Net.Http.HttpRequestException: An error occurred while sending the request. 
---> System.Net.WebException: Unable to connect to the remote server 
---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.26.17.212:8080\r\n 
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)\r\n at System.Net.ServicePoint. 
ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)\r\n 
    --- End of inner exception stack trace ---\r\n at System.Net.HttpWebRequest. 
EndGetResponse(IAsyncResult asyncResult)\r\n at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)\r\n 
--- End of inner exception stack trace ---\r\n --- End of inner exception stack trace ---\r\n at System.Threading. 
Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n at Web_Api_ServerTest.Controllers.EmployeeController. 
<Login>d__0.MoveNext()\r\n---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. 
---> System.Net.WebException: Unable to connect to the remote server 
---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.26.17.212:8080\r\n 
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)\r\n at System. 
Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)\r\n 

下面是代码,我认为是导致此:

[ActionName("Login")] 
    [HttpGet] 
    [CacheFilter(TimeDuration = 100)] 
    public async Task<string> Login([FromUri]string id, string netPwd) 
    { 
     using (HostingEnvironment.Impersonate()) 
     { 
      try 
      { 
       HttpClientHandler hndlr = new HttpClientHandler(); 
       hndlr.UseDefaultCredentials = true; 
       HttpClient client = new HttpClient(hndlr); 

       client.BaseAddress = new 
       Uri("http://172.26.17.212/webapi_publish/api/employee/Login/" 
       + id + "?netpwd=" + netPwd); 

       // Add an Accept header for JSON format. 
       client.DefaultRequestHeaders.Accept.Add(
       new MediaTypeWithQualityHeaderValue("application/json")); 

       HttpResponseMessage response = client.GetAsync(client.BaseAddress).Result; 

       if (response.IsSuccessStatusCode) 
       { 
        dt = response.Content.ReadAsStringAsync().Result; 
       } 
      } 

      catch (Exception ex) 
      { 

       dt = ex.ToString(); 
      } 
     } 
     return dt; 
    } 

回答

0

从错误你得到,它看起来像你无法访问服务器的http端口。

请求您的管理员检查您的网络设置是否正常,或允许此端口在您的防火墙中访问。