小编Rya*_*ala的帖子

GetAsync:不返回HttpResponseMessage

应用程序应该从LoginUser()接收httpresponsemessage但它没有响应.

    private void button1_Click(object sender, EventArgs e)
    {
        if (LoginUser(tUser.Text, Password.Text).Result.IsSuccessStatusCode)
        {
            Notifier.Notify("Successfully logged in.. Please wait!");

        }
        else
        {
            Notifier.Notify("Please check your Credential..");
        }            
    }
Run Code Online (Sandbox Code Playgroud)
    public async Task<HttpResponseMessage> LoginUser(string userid, string password)
    {
        string URI = "http://api.danubeco.com/api/userapps/authenticate";

        using (var client = new HttpClient())
        {
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("c291cmF2OmtheWFs");

            using (var response = await client.GetAsync(String.Format("{0}/{1}/{2}", URI, userid, password)))
            {
                return response;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

请帮忙!

c# asynchronous async-await webapi2 httpresponsemessage

1
推荐指数
1
解决办法
2196
查看次数