来自IIS7上的ASP.NET应用程序的FTP失败

时间:2020-12-18 18:09:41

I have a problem that only occur when I run my application from the IIS.

我有一个问题,只有当我从IIS运行我的应用程序时才会出现。

I am trying to FTP from my ASP.NET application to an external site.

我正在尝试从我的ASP.NET应用程序FTP到外部站点。

I can FTP from the server in general but not from my application. My request times out.

我可以从服务器FTP一般但不能从我的应用程序。我的请求超时了。

The owner of my Website is now set to the IIS_IUSRS user with Full control.

我的网站所有者现在设置为具有完全控制权的IIS_IUSRS用户。

Do anyone have ANY idea what might keeps me from succeeding?

有没有人知道什么可能阻止我成功?

Any help will be extremely appriciated.

任何帮助将非常适合。

My Deadline is within 12 hours and I am royaly screwed...

我的截止日期是12个小时之内,我被罗嗦了......

3 个解决方案

#1


A quick fix may be setting the anonymous user that IIS uses to your user account instead of the IUSR account (in IIS). It does seem to be a permission problem.

快速修复可能是将IIS使用的匿名用户设置为您的用户帐户而不是IUSR帐户(在IIS中)。它似乎确实是一个许可问题。

Second bet would be to use a tool like Wiresharck/Etherreal and check if any connection to the FTP site is made, and debug from there.

第二个赌注是使用像Wiresharck / Etherreal这样的工具,并检查是否有任何与FTP站点的连接,并从那里进行调试。

#2


I Found the Solution

我找到了解决方案

Windows Firewall and non-secure FTP traffic

Windows防火墙和非安全FTP流量

Windows firewall can be configured from command line using netsh command. 2 simple steps are required to setup Windows Firewall to allow non-secure FTP traffic

可以使用netsh命令从命令行配置Windows防火墙。设置Windows防火墙以允许非安全FTP流量需要2个简单步骤

1) Open port 21 on the firewall

1)在防火墙上打开端口21

netsh advfirewall firewall add rule name="FTP (no SSL)" action=allow protocol=TCP dir=in localport=21

netsh advfirewall防火墙添加规则名称=“FTP(无SSL)”action = allow protocol = TCP dir = in localport = 21

2) Activate firewall application filter for FTP (aka Stateful FTP) that will dynamically open ports for data connections

2)激活FTP(又名状态FTP)的防火墙应用程序过滤器,它将动态打开数据连接端口

netsh advfirewall set global StatefulFtp enable

netsh advfirewall设置全局StatefulFtp启用

I don't really know what that just did but it did the trick

我真的不知道刚刚做了什么,但它确实做到了

#3


Same problem solve UsePassive. Maybe you can add allow port 20,21 for FTP on firewall (For me not necessery).

同样的问题解决了UsePassive。也许你可以在防火墙上为FTP添加允许端口20,21(对我来说不是必需的)。

FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"ftp://ftp.example.com/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential("user", "password");
reqFTP.Proxy = null;
reqFTP.KeepAlive = false;
reqFTP.UsePassive = true;

#1


A quick fix may be setting the anonymous user that IIS uses to your user account instead of the IUSR account (in IIS). It does seem to be a permission problem.

快速修复可能是将IIS使用的匿名用户设置为您的用户帐户而不是IUSR帐户(在IIS中)。它似乎确实是一个许可问题。

Second bet would be to use a tool like Wiresharck/Etherreal and check if any connection to the FTP site is made, and debug from there.

第二个赌注是使用像Wiresharck / Etherreal这样的工具,并检查是否有任何与FTP站点的连接,并从那里进行调试。

#2


I Found the Solution

我找到了解决方案

Windows Firewall and non-secure FTP traffic

Windows防火墙和非安全FTP流量

Windows firewall can be configured from command line using netsh command. 2 simple steps are required to setup Windows Firewall to allow non-secure FTP traffic

可以使用netsh命令从命令行配置Windows防火墙。设置Windows防火墙以允许非安全FTP流量需要2个简单步骤

1) Open port 21 on the firewall

1)在防火墙上打开端口21

netsh advfirewall firewall add rule name="FTP (no SSL)" action=allow protocol=TCP dir=in localport=21

netsh advfirewall防火墙添加规则名称=“FTP(无SSL)”action = allow protocol = TCP dir = in localport = 21

2) Activate firewall application filter for FTP (aka Stateful FTP) that will dynamically open ports for data connections

2)激活FTP(又名状态FTP)的防火墙应用程序过滤器,它将动态打开数据连接端口

netsh advfirewall set global StatefulFtp enable

netsh advfirewall设置全局StatefulFtp启用

I don't really know what that just did but it did the trick

我真的不知道刚刚做了什么,但它确实做到了

#3


Same problem solve UsePassive. Maybe you can add allow port 20,21 for FTP on firewall (For me not necessery).

同样的问题解决了UsePassive。也许你可以在防火墙上为FTP添加允许端口20,21(对我来说不是必需的)。

FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"ftp://ftp.example.com/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential("user", "password");
reqFTP.Proxy = null;
reqFTP.KeepAlive = false;
reqFTP.UsePassive = true;