响应状态:404在wp8.0中使用HttpClient

时间:2014-08-30 16:03:04

标签: windows-phone-8 httpclient webrequest

我有这个代码工作,但现在突然它不会返回 "响应状态代码不表示成功:404()" .. 什么可能是它不重要的URL ..

下面是代码:

 protected async void getstring(string url)
    {
        HttpClient client = new HttpClient();
       client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");

        try
        {
            var html = await client.GetStringAsync(url);
            extractData(html);
        }
        catch (HttpRequestException e)
        {

            MessageBox.Show(e.Message);
            arrivalTime.Text = e.Message;
        }

        //time.Text = html;


    }

0 个答案:

没有答案