1
string url = "http://192.168.1.127/xia/Server/xia.asp?COMMAND=Login&Account=puretime&Password=12345";
2
3
CookieContainer cookie = new CookieContainer ();
4
5
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
6
7
myRequest.AllowAutoRedirect = true;
8
9
myRequest.CookieContainer = cookie;
10
11
HttpWebResponse myresponse = (HttpWebResponse)myRequest.GetResponse();
12
13
myresponse.Cookies = cookie.GetCookies(myRequest.RequestUri);
14
15
Stream mystream = null;
16
17
mystream = myresponse.GetResponseStream();
18
19
StreamReader myreader = new StreamReader(mystream, System.Text.Encoding.Default, true);
20
21
string pagefile = myreader.ReadToEnd();
22
23
if (pagefile.IndexOf("<Value>1</Value>") > 0)//登入成功
24
w.Close();
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24