2017-06-30 176 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端口。

請求您的管理員檢查您的網絡設置是否正常,或允許此端口在您的防火牆中訪問。