title: Android Emulator with Localhost ASP.Net Core API Calls
body: <p>I've been trying to perform a GET request from Visual Studio's Android Emulator to an ASP.Net Core API running on localhost. I first read that I have to use IP <code>10.0.2.2</code> when performing the request from Android, so I have the following HTTP client code in my Android (Xamarin) App</p>
  
  <pre><code>protected override void OnCreate(Bundle bundle)
          {
              base.OnCreate(bundle);
              SetContentView (Resource.Layout.Main);
  
              var logInbutton = FindViewById&lt;Button&gt;(Resource.Id.logInButton);
  
              logInbutton.Click += OnLogInButtonClicked;
          }
  
          private async void OnLogInButtonClicked(object sender, EventArgs e)
          {
              using (var client = new HttpClient())
              {
                  client.DefaultRequestHeaders.Accept.Clear();
                  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
  
                  var uri = new Uri("http://10.0.2.2:5555/api/Orders?api-version=0.9");
                  var response = await client.GetAsync(uri);
              }
          }
  </code></pre>
  
  <p>However, each time I attempt to run this I'm greeted with a <code>400 Bad Request</code> error. I know the request is okay since I can run the same Http client code from a console app without any errors. I then read that IIS express does not accept external requests and since the Android emulator is running in a VM this could be the reason. </p>
  
  <p>So I then followed the advice on this <a href="https://stackoverflow.com/questions/6192726/android-emulator-loopback-to-iis-express-does-not-work-but-does-work-with-cassi">SO post</a> but was greeted with an <code>Invalid URI: The hostname could not be parsed</code> error. I'm not sure how to proceed from here. Is there a solution to the <code>Invalid URI: The hostname could not be parsed</code> error, or should I attempt to circumvent IIS Express and run solely with kestrel for development? Would even running solely in kestrel fix this problem?</p>