Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Getting “Unable to connect to the remote server” When I call WebAPI Url (C#)

Getting “Unable to connect to the remote server” When I call WebAPI Url (C#)

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpcsharpsysadminjson
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sfd
    wrote on last edited by
    #1

    Below Code which I have tried:

    NetworkCredential myCred = new NetworkCredential("xxxxx@xx.xxx.xxx", "xxxxxxxx");
    using (var handler = new HttpClientHandler { Credentials = myCred })
    {
    HttpClient client = new HttpClient(handler);
    client.BaseAddress = new Uri("https://xxxxx.xxx.xx:2601/api/getallprices");
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(client.BaseAddress);
    HttpWebResponse WebResp = (HttpWebResponse)request.GetResponse();
    }

    Here when I tried to get response from request url, it throws an error

    "Unable to connect to remote server"...

    Can please anyone help me out to solve this error !!

    Richard DeemingR 1 Reply Last reply
    0
    • S sfd

      Below Code which I have tried:

      NetworkCredential myCred = new NetworkCredential("xxxxx@xx.xxx.xxx", "xxxxxxxx");
      using (var handler = new HttpClientHandler { Credentials = myCred })
      {
      HttpClient client = new HttpClient(handler);
      client.BaseAddress = new Uri("https://xxxxx.xxx.xx:2601/api/getallprices");
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(client.BaseAddress);
      HttpWebResponse WebResp = (HttpWebResponse)request.GetResponse();
      }

      Here when I tried to get response from request url, it throws an error

      "Unable to connect to remote server"...

      Can please anyone help me out to solve this error !!

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      The URL is wrong, or the port is wrong, or one of the firewalls between the client and the server is blocking the request. You'll need to look at the details of the exception and debug the connection. We can't do that for you. For example, if the error says "the target machine actively refused", that normally points to a firewall. If it's a timeout, then the URL or port is wrong.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups