According to https://learn.microsoft.com/en-us/dotnet/api/system.net.ftpwebrequest.proxy?view=netcore-3.1 FtpWebRequest
does not support proxy with .NET Core. Is there an alternative?
I need to access a FTP file via some squid proxy (i.e. FTP over HTTP) with proxy authentication (NTLM).
This is example code:
FtpWebRequest request = (FtpWebRequest) WebRequest.Create("ftp://ftp.ubuntu.com/");
var proxy = new WebProxy("my.squid.host", 8080);
proxy.Credentials = new NetworkCredential("squid_user", "squid_pass");
request.Proxy = proxy;
WebResponse response = request.GetResponse();
var result = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine(result);
If you replace squid host/user/pass in this code with yours, you will see this works fine with this csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
</Project>
But it no longer works with .NET Core:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>