locked
How to communicate with Unix Server from ASP.Net RRS feed

  • Question

  • User1555051773 posted

    Hi,

    According to our requirement, from asp.net page we need to communicate UNIX server and from there we need to get the image and then need to display in the asp.net web page. Howe we can achieve this task. Please help me on this.

    Thank you..

    Tuesday, August 28, 2018 1:15 PM

All replies

  • User753101303 posted

    Hi,

    The first step would be to understand which kind of "communication channel" you have between those two servers : http(s), ftp, network shares etc...

    Tuesday, August 28, 2018 3:39 PM
  • User283571144 posted

    Hi saravanangj,

    According to your description, I suggest you could conside using SSH.NET to conenct to the UNIX server, then you could run ssh command to get the file or something else.

    Install SSH.NET from Nuget:

    https://www.nuget.org/packages/SSH.NET/ 

    More details about how to run shh command on Unix in asp.net, you could refer to below codes:

    Article:

    https://www.codeproject.com/Articles/11966/sharpSsh-A-Secure-Shell-SSH-library-for-NET 

    Test Code:

    using Renci.SshNet;
    using System;
    
    namespace ConsoleApp
    {
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    using (var client = new SshClient("server ip address", "your user name", "your password"))
                    {
                        client.Connect();
                        Console.WriteLine("Connected");
    
                        string result = client.RunCommand("ifconfig -a").Execute();
                        Console.WriteLine(result);
    
                        client.Disconnect();
                        Console.WriteLine("Disconnected");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
    
                Console.ReadLine();
            }
        }
    }
    

    Result:

    Best Regards,

    Brando

    Wednesday, August 29, 2018 7:01 AM