Search code examples
androidasp.netiishttpconnection

Bad request when connecting to ASP.NET page on IIS from android application


I have a ASP.NET website deployed to IIS with a couple of ashx that returns JSONs to be consumed by an Android application. I have implemented an authentication logic using Basic Authentication.

The problem: When accessed from Android, the server response is a 400 Bad request. The httperr log file says "400 - Hostname -".

  • It works when I try it out on localhost from Android emulator
  • It works when accessing the ashx file on the server from a browser
  • It works when replicating the call in Fiddler

(If I use Fiddler with the Android Emulator, the Response will be -1 (and looking in Fiddler at the raw data sent, it seems to loose the host from the url) - but this is another issue so don't dwell on that, i just thought I would mention it...)


Solution

  • Turns out my problem (and solution) was the same as in this thread:

    HTTP POST request with authorization on android