2012-12-11 3 views
1

MVC4 응용 프로그램은 HomeController의 작업에서 FTP 서버의 파일을 다운로드합니다. Visual Studio 2010 웹 서버와 로컬 웹 서버 인 IIS Express 8을 통해 작동합니다. 그러나 로컬 웹 서버 IIS 7.5을 ApplicationPoolIdenty와 함께 사용하면 다운로드가 작동하지 않습니다. "response = reqFTP.GetResponse()"명령 줄에 응답을받지 못하고 예외가 표시됩니다. "작업 시간 초과되었습니다 ").아니요 IIS 7.5이 설치된 FtpWebRequest.GetResponse 및 Visual Studio 2010 Web Server 및 IIS Express가 설치된 방화벽 8

Windows 방화벽을 해제하면 작동합니다. 내가해야하는 것?

Function FtpStart() As ActionResult 
     Dim downloadFiles As String() 
     Dim result As New StringBuilder() 
     Dim response As WebResponse = Nothing 
     Dim reader As StreamReader = Nothing 
     Try 
      Dim reqFTP As FtpWebRequest 
      reqFTP = DirectCast(FtpWebRequest.Create(New Uri("ftp://adress")),FtpWebRequest) 
      reqFTP.UseBinary = True 
      reqFTP.Credentials = New NetworkCredential("user", "pw") 
      reqFTP.EnableSsl = False 
      reqFTP.Method = WebRequestMethods.Ftp.ListDirectory 
      reqFTP.Proxy = Nothing 
      reqFTP.KeepAlive = False 
      reqFTP.UsePassive = False 
      Debug.WriteLine("Get Response: ") 
      response = reqFTP.GetResponse() 
      Debug.WriteLine("Response received") 
      reader = New StreamReader(response.GetResponseStream()) 
      Dim line As String = reader.ReadLine() 
      While line IsNot Nothing 
       result.Append(line) 
       result.Append(vbLf) 
       line = reader.ReadLine() 
       Debug.WriteLine("File: " & line) 
      End While 
      result.Remove(result.ToString().LastIndexOf(ControlChars.Lf), 1) 
      Return RedirectToAction("Index") 
     Catch ex As Exception 
      Debug.WriteLine(ex.ToString()) 
      Return RedirectToAction("Index") 
     End Try 
    End Function 

답변

0

오늘 내 웹 서버에서이 문제가 발생했습니다. 포트 20 및 21에 대한 TCP의 인바운드 규칙에 대해 방화벽에 규칙을 설정해야합니다. 로컬 포트 ​​= 모든 포트 및 원격 포트 = 20-21이 표시되어야합니다. 또한 고급 탭에서 세 개의 체크 표시가 모두 도메인, 비공개 및 공개로 선택되어 있는지 확인하십시오. 방화벽에는 포트 21에 대한 규칙을 설정하자마자 20 번 포트가 아니라 21 번 포트에 대한 FTP 방화벽 규칙이 이미 있습니다.

희망이 도움이되었습니다.

관련 문제