0

我已经用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));
4

1 回答 1

0

You set credentials like this:

WebClient httpclient = new WebClient();

username = txtUname.Text;
password = txtPass.Text;

httpclient.Credentials = new NetworkCredential(username, password);

Where txtUname and txtPass are TextBox elements.

In order to POST, it's been answered here.

于 2012-10-13T14:59:49.620 回答