locked
'System.ArgumentException' at var strHtml = await httpClient.GetStringAsync("http://www.justjaredjr.com/");

    Question

  • An exception of type 'System.ArgumentException' occurred in Entertaiment.Windows.exe but was not handled in user code
    
    Additional information: Value does not fall within the expected range.

    Here code

    public async System.Threading.Tasks.Task<List<ViewModel.News>> NewsPat() { var httpClient = new HttpClient();

      var strHtml = await httpClient.GetStringAsync("http://www.justjaredjr.com/");


    I don't understand why is it always show this error at strHtml ???. How ways to solve?

    Wednesday, April 22, 2015 3:00 AM

Answers

  • It works fine if you put in the right parameter:

    var strHtml = await httpClient.GetStringAsync(new Uri("http://www.justjaredjr.com/"));


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, April 22, 2015 12:45 PM
    Moderator