0

The content is returning null. I don't understand why. If I put a Json string into the content variable the function will work how I want it to work. but i cant get the json file directly from the url. I saw that there is another way of downloading the json which is Webclient but that don't work it says the variable or namespace could not be found. Even though I imported using System.Net; I tried it on a console app and it works but not in the windows phone app.

public async void ParcingJ()
{     
  HttpClient httpClient = new HttpClient();
  string content = await httpClient.GetStringAsync( 
                         new Uri("http://localhost/test.php"));         
  JArray jsonObject = JArray.Parse(content);      
  txtOut.Text = content;
}
0

1 Answer 1

2

Your windowsphone emulator can't access the localhost of your host machine.

This is why it works in your console app, but not on the phone.

One solution would be to host your script on a public web server and access it from there with a proper public URL.

Sign up to request clarification or add additional context in comments.

2 Comments

thank you... that was the problem...because I tried someone else json link and it works..
I was able to Configure Apache on wamp and it works there for free... thanks you save me allot of hours... I spent over 9 hours trying to figure out whats wrong...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.