StatusCode:500内部服务器错误

时间:2018-07-20 05:30:30

标签: c# xamarin.forms xamarin.android

发送POST请求时出现500个内部服务器错误。

代码:

private async void btnRegister_Clicked(object sender, EventArgs e)
        {
            Users user = new Users()
            {
                mem_account_no = entId.Text,
                mem_acc_username = entUsername.Text,
                mem_acc_password = entPassword.Text
            };
            //signup.Text = user.mem_account_no;

            var json = JsonConvert.SerializeObject(user);

            var content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpClient client = new HttpClient();

             var result = await client.PostAsync("http://ropenrom24-001-site1.etempurl.com/potangina/final/Restserver/index.php/users/insert", content);

            if (result.StatusCode == System.Net.HttpStatusCode.Created)
            {
                await DisplayAlert("Success", "Success" , "OK");
            }
            else
            {
                await DisplayAlert("Failed", "" + result, "OK");
            }
        }

我认为这里的问题是对象(用户)到json的序列化,因为在显示Content-Type: txt/html;时看到了var result,而在Windows窗体上却显示了Content-Type: application/json;。顺便说一句,我的Anrdoid和Windows表单具有相同的代码。

0 个答案:

没有答案