I have a WebApi application that runs on IIS.
In development it works perfectly reading and writing files. When it is deployed to the live system it will login but not list the contents of the folders. This has worked in the past and I cannot work out what has changed to make it stop working.
I am using FluentFTP using the following code.
Dim Host As String = FTPSettings.Val("Host")
Dim Port As Integer = CInt(FTPSettings.Val("Port"))
Dim UserName As String = FTPSettings.Val("Username")
Dim Password As String = FTPSettings.Val("Password")
Dim Client As FtpClient
Dim Creds As New NetworkCredential(UserName, Password)
Client = New FtpClient(Host) With {
.Port = Port,
.Credentials = Creds,
.EncryptionMode = FtpEncryptionMode.Explicit,
.SslProtocols = System.Security.Authentication.SslProtocols.Tls12,
.DataConnectionType = FtpDataConnectionType.PASV
}
Dim OrgID = 1
Dim Filelist() As FtpListItem
Client.SetWorkingDirectory($"/{OrgID.ToString}")
Filelist = Client.GetListing(Client.GetWorkingDirectory())
FTPSettings is an internal system that retrieves settings from the database.
I am trying to return the variable FileList from the function but get a "Object reference not set to an instance of an object".
Things I have tried:
- Changing the connection type (to active)- No error but brings back an empty list
- Tried BulkListing - Same error
- Opening various firewall ports inbound and outbound
- Try catch around the Client.GetListing line. No more details returned.
All of the changes I have made above still work on the test system but not on the live.
At this point I am thinking there is a issue with the setup on the live machine but I am not sure where it is.