System.Net.WebClient.UploadValues C# (CSharp) Method

UploadValues() public method

public UploadValues ( System address, System data ) : byte[]
address System
data System
return byte[]
        public byte[] UploadValues(System.Uri address, System.Collections.Specialized.NameValueCollection data) { throw null; }
        public byte[] UploadValues(string address, string method, System.Collections.Specialized.NameValueCollection data) { throw null; }

Same methods

WebClient::UploadValues ( System address, string method, System data ) : byte[]
WebClient::UploadValues ( string address, System data ) : byte[]
WebClient::UploadValues ( string address, string method, System data ) : byte[]

Usage Example

Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            System.Net.WebClient WebClientObj = new System.Net.WebClient();

            System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection();

            PostVars.Add("userPass", textBox2.Text.Trim());

            PostVars.Add("userName", textBox1.Text.Trim());

            PostVars.Add("platform", "android");

            try

            {
                WebClientObj.Encoding = Encoding.UTF8;

                byte[] byRemoteInfo = WebClientObj.UploadValues("http://xxzy.xinkaoyun.com:8081/holidaywork/login", "POST", PostVars);

                //下面都没用啦,就上面一句话就可以了

                string sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo);

                LoginObj = JsonConvert.DeserializeObject <Root_1>(sRemoteInfo);

                PostVars.Clear();

                PostVars.Add("token", LoginObj.data.andToken);

                byRemoteInfo = WebClientObj.UploadValues("http://xxzy.xinkaoyun.com:8081/holidaywork/student/getStudent", "POST", PostVars);

                sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo);

                MessageBox.Show(LoginObj.msg);

                LoginObj_2 = JsonConvert.DeserializeObject <Root_2>(sRemoteInfo);

                if (LoginObj.msg == "登录成功")
                {
                    this.Hide();
                    main.Show();
                }
                //这是获取返回信息
            }

            catch
            {
            }
        }
All Usage Examples Of System.Net.WebClient::UploadValues