tufekoi
tufekoi

Reputation: 991

Windows.Web.Http.HttpClient throws continuously error 404

I'm trying to use the Windows.Web.Http.HttpClient class but it keeps throwing me an 404 error, even if I try the code from the doc :

var uri = new Uri("http://example.com/datalist.aspx");
var httpClient = new HttpClient();

try
{
    var result = await httpClient.GetStringAsync(uri);
    Debug.WriteLine("content : {0}", result);
}
catch (Exception e)
{
    Debug.WriteLine("error : {0}", e.Message);
}

And this is the error :

A first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll
error : Not found (404).

Response status code does not indicate success: 404 (Not Found).

link of the doc I used

I can access the address from the phone with a web browser like IE.

Upvotes: 1

Views: 865

Answers (1)

Amir Popovich
Amir Popovich

Reputation: 29836

That's because it does return a 404 (use a sniffer and check).

Change the url to http://www.example.com and things will work.

The site returns the same response on all requests. You can try:

http://www.example.com/mynickistuff.abcd

Upvotes: 2

Related Questions