I have an incoming FTP request. I would like to get the IP Address of the FTP server mentioned in the incoming FTP request. I have to validate this against a list of whitelisted FTP servers.
Any help will be well appreciated..
My code is as follows:
try
{
    IPHostEntry host;
    string localIP = "?";
    host = Dns.GetHostEntry(uri);
    foreach (IPAddress ip in host.AddressList)
    {
        // we are only interested in IPV4 Addresses
        if (ip.AddressFamily == AddressFamily.InterNetwork) 
        {
            localIP = ip.ToString();
        }
    }
    return localIP;
}
catch (Exception exception)
{
    throw;
}
 
     
    