我已经用android完成了这个。现在我正在尝试在Windows Phone 7中执行此操作。在c#中,此代码的等效内容是什么?我还想将源代码保存在字符串中。
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://students.usls.edu.ph/login.cfm");
username = txtUname.getText().toString();
password = txtPass.getText().toString();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username",username));
nameValuePairs.add(new BasicNameValuePair("password",password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
答案 0 :(得分:0)
您可以像这样设置凭据:
WebClient httpclient = new WebClient();
username = txtUname.Text;
password = txtPass.Text;
httpclient.Credentials = new NetworkCredential(username, password);
其中txtUname和txtPass是TextBox元素。
为了发帖,已经回答here。