|
HTTPWebRequest已经得到了很好的解决。如果是用FtpWebRequest 又该怎么解决呢?
我的机器A 存放资源的机器C 代理机器B。 C上已经搭建了FTP站点且只能B访问,A可以访问B机器以获取C上的资源。 也就是说B是作为代理服务器存在的。
[code=csharp] WebResponse ftpResponse = null;
FtpWebRequest ftpRequest = (FtpWebRequest)FtpWebRequest.Create(textBoxFtpUrl.Text);
ftpRequest.Credentials = new NetworkCredential(textBoxUserName.Text, textBoxPassword.Text);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
ftpRequest.KeepAlive = false;
ftpRequest.UsePassive = checkBoxUsePassive.Checked;
int timeout = (int)numericUpDownTimeout.Value;
if (timeout <= 0)
{
ftpRequest.Timeout = System.Threading.Timeout.Infinite;
}
else
{
ftpRequest.Timeout = timeout * 1000;
}
WebProxy proxy = new WebProxy(txtProxyIP.Text.Trim(), Convert.ToInt32(txtProxyPort.Text.Trim()));
proxy.Credentials = new NetworkCredential(txtProxyUserName.Text.Trim(), txtProxyPassword.Text.Trim());
ftpRequest.Proxy = proxy;
ftpResponse = ftpRequest.GetResponse(); //走到这里出现错误 "服务器提交了协议冲突. Section=ResponseStatusLine" 修改
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing= "true"/> 无效[/code] |
|