Windows phone8.1 Academic Online Client

Source: Internet
Author: User

I am a sophomore student, because the school's education online has not out of the Windows Phone's Dean online, and itself is also interested in WP development, so try to develop

Because there is no systematic learning, only in the groping forward, the rationale behind this is very simple, not easy to achieve, the web is not suitable for the tutorial, the following is I try to write the code of the login page,

But there are some grammatical problems, I hope to help see

Using System;
Using System.Collections.Generic;
Using System.IO;
Using System.Linq;
Using System.Net;
Using System.Runtime.InteropServices.WindowsRuntime;
Using Windows.foundation;
Using Windows.Foundation.Collections;
Using Windows.UI.Xaml;
Using Windows.UI.Xaml.Controls;
Using Windows.UI.Xaml.Controls.Primitives;
Using Windows.UI.Xaml.Data;
Using Windows.UI.Xaml.Input;
Using Windows.UI.Xaml.Media;
Using Windows.UI.Xaml.Navigation;
Using System.Collections.Specialized;
Using System.Text;
Using System.Xml.Linq;
Using System.Threading.Tasks;
Using System.Text.RegularExpressions;
Public sealed partial class Mainpage:page
{
Public MainPage ()
{
This. InitializeComponent ();

This. Navigationcachemode = navigationcachemode.required;
}
Private async void Button_Click (object sender, RoutedEventArgs e)
{
The spelling of this postdata may be wrong, consider the way to use key-value pairs
String loginstr = "J_username=" + TextBox1.Text + "&j_password=" + passwordbox.tostring ();

Cookiecontainer cookie = await GetCookie (loginstr, "http://60.18.131.131:11080/newacademic/common/security/login.jsp");
String content = await getcontent (cookie, "http://60.18.131.131:11080/newacademic/frameset.jsp");
Frame.navigate (typeof (BlankPage1), content);
TextBox2.Text = content;
}

Public Async task<cookiecontainer> GetCookie (string poststring,string posturl)
{
Cookiecontainer cookie = new Cookiecontainer ();
HttpWebRequest HttpRequest = (HttpWebRequest) webrequest.create (PostURL);
I don't know how to improve the information on this request header, but I'll add it anyway.
Httprequest.cookiecontainer = cookie;//Set Cookie
Httprequest.method = "POST";//post commit
httprequest.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
Httprequest.contenttype = "application/x-www-form-urlencoded";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes (poststring);
Stream stream = await httprequest.getrequeststreamasync ();
Stream. Write (bytes, 0, bytes. LENGTH);//above is the post data write, I do not know what the omission of the place
HttpWebResponse HttpResponse = (HttpWebResponse) await Httprequest.getresponseasync ();
return cookie;
}

Public async task<string> getcontent (cookiecontainer cookie,string URL)
{
string content;
HttpWebRequest HttpRequest = (HttpWebRequest) httpwebrequest.create (URL);
Httprequest.cookiecontainer = cookie;
httprequest.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
Httprequest.contenttype = "application/x-www-form-urlencoded";
Httprequest.method = "GET";
HttpWebResponse HttpResponse = (HttpWebResponse) await Httprequest.getresponseasync ();
using (Stream Responsestream = Httpresponse.getresponsestream ())
{
using (StreamReader sr = new StreamReader (Responsestream,system.text.encoding.utf8))
{
Content = Sr. ReadToEnd ();
}
}
return content;
}
}
}

The logic is basically to first simulate landing, then get a cookie, and then take this cookie to access the landing page, (and then by parsing HTML to get the content you want, this part has not been done)

However, it is not possible to get the content returned, I hope the experienced Park friends to guide

Windows phone8.1 Academic Online Client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.