Hi, I'm trying to upload files to a FTP server. I've tried using old piece of code I've used ASP.NET MVC 5 but DNX Core does not see to provide FtpWebRequest class for FTP manipulation. One workaround has come to my mind to use HttpClient with external Web service (WebAPI 2) which will upload my files, but I would have to maintain two applications and I don't like this approach... So is there any other approach I could use and I'm apparently missing? Thanks!
I believe FtpWebRequest
is not available on .Net Core. WebRequest
on .Net Core is just a wrapper around HttpCLient
and it does not support FTP. I also didn't find any Core-compatible packages for FTP after a cursory search of NuGet.
The confusing thing is that if you remove the cast to FtpWebRequest
, and don't set FtpWebRequest
-specific properties, then WebRequest.Create()
succeeds (I think it's because of this line), but then fails when you actually try to retrieve the request. Is there any reason to pretend FTP is supported like this?
These lines in WebRequest.cs
should have never been ported to CoreFx:
c#
prefixList.Add(new WebRequestPrefixElement("file:", new HttpRequestCreator()));
prefixList.Add(new WebRequestPrefixElement("ftp:", new HttpRequestCreator()));
CoreFx doesn't support file: or ftp: schemes for WebRequest classes. Only the HttpWebRequest is supported on CoreFx.
We will submit a PR to fix this.
cc: @stephentoub
@davidsh Any plan to support it by RTM?
Any plan to support it by RTM?
What do you mean by "it"? If you mean "we will support FtpWebRequest class in CoreFx", the answer is no. We have no plans to do that. There are better architectures and coding patterns for Ftp than the 'FtpWebRequest' pattern. There are several 3rd party libraries (FtpClient) out there.
Not FtpWebRequest
per se. Just 'FTP'. Is it something the team want to spend time on or is it a scenario where the decision has been made to rely on 3rd party libraries?
Currently Ftp is not a priority. And there are many 3rd party libraries to fill the gap right now.
@davidsh Are you aware of any third party FTP libraries that support .Net Core?
I am not aware of any specific libraries that target .NET Core. But we haven't really been looking lately. As I mentioned, Ftp is not a priority for the team right now.
Thanks for the clarification @davidsh
Does anyone know which ftp utility can be used with .NETCore RC2?
there are many 3rd party libraries to fill the gap right now.
I am not aware of any specific libraries that target .NET Core.
Eh? :)
Here is one potential: CoreFTP, although i have yet to use it.
What are these better architectures and patterns you spreak of?
FtpWebRequest is supported now as part of .NET Core 2.0 (NETStandard2.0).
You can try it out in the previews releases or use the daily code in master branch.
Most helpful comment
Does anyone know which ftp utility can be used with .NETCore RC2?