Windows phone 8 Http客户端 - 发布数据

时间:2014-08-05 22:32:56

标签: c# http windows-phone

我正在开发Windows Phone 8应用程序。我需要使用HTTP POST方法发送一些数据,但它不起作用:

这是我的代码:

 public async Task<bool> ConnexionPage()
    {
        bool _verif = false;
        var client = new HttpClient();
        string data = "username=" + this.user + "&password=" + this.password + "&cmdweblogin=Enter";
        var postContent = new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded");

        // send request asynchronously and continue when complete 
        var response = await client.PostAsync("http://intranet.ifips.u-psud.fr/ii/index.php?id=571", postContent).ConfigureAwait(continueOnCapturedContext: false); 

        // check that response was successful or throw exception response.EnsureSuccessStatusCode();
        response.EnsureSuccessStatusCode();
        //Read the JSON response
        var content = await response.Content.ReadAsStringAsync();
        _verif=true;
        return _verif;
    }

当我使用断点时,我被阻止在第var response = await client.PostAsyn行...

0 个答案:

没有答案