首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在IIS7.5和防火墙上没有FtpWebRequest.GetResponse,但在Visual Studio2010 IIS服务器和IISExpress8上没有

在IIS7.5和防火墙上没有FtpWebRequest.GetResponse,但在Visual Studio2010 IIS服务器和IISExpress8上没有
EN

Stack Overflow用户
提问于 2012-12-11 21:54:01
回答 1查看 384关注 0票数 1

MVC4应用程序通过来自HomeController的操作从FTP服务器下载文件。在visual Studio2010 the服务器和本地the服务器IIS Express 8上,它可以正常工作。但是当我使用带有ApplicationPoolIdenty的本地when服务器IIS7.5时,下载无法工作:我没有收到命令"response = reqFTP.GetResponse()“的响应,并且出现以下异常:”操作已超时“)。

当我关闭Windows-Firewall时,它工作了。我需要做什么?

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2014-12-16 09:10:49

今天早些时候我在我的web服务器上遇到了这个问题。您必须在防火墙上为端口20和21的TCP入站规则设置一个规则。应显示Local port = all ports,remote ports = 20-21。还要确保在advanced选项卡上,选中了domain、private和public的所有三个复选标记。我的防火墙已经为端口21设置了FTP防火墙规则,但没有为20设置规则,一旦我为端口20设置了规则,它就起作用了。

希望这能有所帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13821832

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档