1

i created Console Application in C# and in that i'm calling some external API using HTTPClient which is working fine in Windows server but the same is not working with Linux server.

Please find the below code

static void Main(string[] args)
        {
            HttpResponseMessage httpResponseMessage = null;
            string contents = string.Empty;
            using (var httpClient = new HttpClient())
            {
                httpResponseMessage = httpClient.GetAsync("example.com").Result;
                contents =  httpResponseMessage.Content.ReadAsStringAsync().Result;
            }
            Console.WriteLine(contents);
            Console.ReadKey();

        }

Need help in executing file in linux i also tried simple hello world and it is working fine.

dev
  • 163
  • 1
  • 11
  • No way to do that because `.exe` is only **Windows executable file format**. To use some code in linux you can develop it on .NET Core and build specially for linux machines. – picolino Mar 12 '20 at 09:41
  • @picolino i tried with **wine filepath.exe** which is working fine without httpclient but the same is not working with httpclient – dev Mar 12 '20 at 09:45
  • Please provide some information about errors you get – picolino Mar 12 '20 at 09:53
  • If you are using .net core, you should build your code for linux. The executable file format of linux and windows is different. – KagurazakaKotori Mar 12 '20 at 10:04
  • @KagurazakaKotori tried with linux executable file but still it is not working. – dev Mar 12 '20 at 10:09

0 Answers0