0

I've done this already with android. Now I'm trying to do it in Windows Phone 7. What is the equivalent of this code in c#? I also want to save the source code in a string.

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));
Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
pmark019
  • 1,199
  • 5
  • 15
  • 24

1 Answers1

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.

Community
  • 1
  • 1
Igor Ralic
  • 14,975
  • 4
  • 43
  • 51
  • how can I retrieve the source code of the website to check that I was able to login? – pmark019 Oct 13 '12 at 15:40
  • Download string asynchronously. Check out this tutorial http://www.dotnetperls.com/webclient – Igor Ralic Oct 13 '12 at 16:02
  • I was able to download the source code but the source code it downloads is of the login screen. I want to download the source code of the next page. How can I do it? – pmark019 Oct 14 '12 at 02:01