1

I am trying to get a response from WebApi application running on my localhost. I can get it from thr browser and I can get it from another web app.

I am, however, having problem with the same code in Xamarin Studio debugging device

var url="http://192.168.2.4:13325/api/values";
using (WebClient wc = new WebClient())
{

    wc.Headers.Add("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    wc.Headers.Add ("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22");
    wc.Headers.Add ("Accept-Encoding","gzip,deflate,sdch");
    wc.Headers.Add ("Accept-Language","en-US,en;q=0.8");
    wc.Headers.Add ("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.3");

    string HtmlResult = wc.DownloadString(url);
}

This is the header taken from Fiddler when doing request from browser. The web app doesn't even need those and gets the response.

I am using my computer's IP, because I read, that the debugger runs a virtual machine, so I can't target localhost.

Matus
  • 410
  • 5
  • 15

2 Answers2

0

I solved this probolem. It was not related to Xamarin or android, problem was on the service side.

First enable external requests: IIS Express enable external request

An then edit binding information for your app: IISExpress returns a 503 error from remote machines

Community
  • 1
  • 1
Matus
  • 410
  • 5
  • 15
0

I had the same problem everything is working good on the browser but connot connect from emulator (i get a 400 bad request) it was very simple i just forgot to launch my web api as administrator