Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用xamarin表单连接到服务器_Xamarin_Cross Platform - Fatal编程技术网

使用xamarin表单连接到服务器

使用xamarin表单连接到服务器,xamarin,cross-platform,Xamarin,Cross Platform,我正在开发Xamarin跨平台应用程序。我正在尝试连接到服务器,我需要发送这些字段password=xyz;平台=iphone;用户电子邮件=test@test.com; 和请求一起。所以服务器将检查这些参数并返回XML。但我们不知道如何将这些字段添加到请求中 当我打开上面的字符串url http://*****/login/clientlogin时,我会看到登录屏幕,其中有用户名、密码和平台文本字段 提前谢谢 这应该让您开始假定您正在请求中添加作为头的值: public class TestC

我正在开发Xamarin跨平台应用程序。我正在尝试连接到服务器,我需要发送这些字段password=xyz;平台=iphone;用户电子邮件=test@test.com; 和请求一起。所以服务器将检查这些参数并返回XML。但我们不知道如何将这些字段添加到请求中

当我打开上面的字符串url http://*****/login/clientlogin时,我会看到登录屏幕,其中有用户名、密码和平台文本字段


提前谢谢

这应该让您开始假定您正在请求中添加作为头的值:

public class TestClient
{

    HttpClient client;

    public TestClient(){
        this.client = new HttpClient ();
    }

    public void AddHeadersAndGet(){
        client.DefaultRequestHeaders.Add ("username", "whatevertheusernameis");
        this.GetAsync<WhateverObjectTypeYouAreReceiving> ("theurloftheservice");
    }

    public async Task<T> GetAsync<T>(string address){
        HttpResponseMessage response = null;
        response = await client.GetAsync (address);
        if (response.IsSuccessStatusCode) {
            try {
                var responseString = await response.Content.ReadAsStringAsync ();
                return new T (Serializer.DeserializeObject<T> (responseString),
                    response.StatusCode);
            } catch (Exception ex) {

            }
        } else {

        }
    }
}

嗨,克林特·兰德利,谢谢你的问答。我不知道如何将这些字段SUSERNAME、密码和域添加到请求中。感谢JrdanMazurke,我的问题已使用RestClient修复。谢谢重播。
client.DefaultRequestHeaders.Add ("username", "whatevertheusernameis");