.net 4.0 在IIS7.5和.NET 4.0上使用FTPWebRequest时出错

.net 4.0 在IIS7.5和.NET 4.0上使用FTPWebRequest时出错,.net-4.0,iis-7.5,ftpwebrequest,.net 4.0,Iis 7.5,Ftpwebrequest,我在ASP.NET Web服务中有一个简单的类。它在我的本地系统上,甚至在我设置的开发环境上都可以正常运行,但每当我尝试在生产服务器上发送文件时,都会出现以下错误: Exception Error: The underlying provider failed on Open. 下面是正在调用的代码: public class FTPHelper { public static string SendFile(string ftpuri, string username, st

我在ASP.NET Web服务中有一个简单的类。它在我的本地系统上,甚至在我设置的开发环境上都可以正常运行,但每当我尝试在生产服务器上发送文件时,都会出现以下错误:

Exception Error: The underlying provider failed on Open.
下面是正在调用的代码:

public class FTPHelper
{
        public static string SendFile(string ftpuri, string username, string password, string ftppath, string filename, byte[] datatosend)
        {
            if (ftppath.Substring(ftppath.Length - 1) != "/")
            {
                ftppath += "/";
            }
            FtpWebRequest ftp = (FtpWebRequest) FtpWebRequest.Create( ftpuri + ftppath + filename);
            ftp.Method = WebRequestMethods.Ftp.UploadFile;
            ftp.Credentials = new NetworkCredential(username, password);
            ftp.UsePassive = true;
            ftp.ContentLength = datatosend.Length;
            Stream requestStream = ftp.GetRequestStream();
            requestStream.Write(datatosend, 0, datatosend.Length);
            requestStream.Close();

            FtpWebResponse ftpresponse = (FtpWebResponse)ftp.GetResponse();

            return ftpresponse.StatusDescription;
        }
    }
如何解决此问题。服务器是在Windows 2008 Server上运行的IIS 7.5。我正在使用.NET4.0。FtpWebResponse不起作用的原因很简单吗


如果这是一个安全问题,那么有什么办法可以解决吗?我需要马上把它修好

这是一个安全问题,网站运行的用户没有建立FTP连接的权限。我是一名程序员,不是网站管理员,所以我不知道如何做到这一点。在搜索了微软关于IIS的IIS帮助后,我终于找到了答案。更改用户的解决方案在超级用户上:


如果有更好的解决方案,请回复。如果有人认为这会引发安全问题,也请发布更多信息

一个星期后,没有一个人能帮我解决这个问题,我感到震惊。即使有赏金,也没有人回答。