本例為Windows Form連接某WEB URL的帳號驗證aspx,傳入帳號與密碼,該系統的網頁程式會驗證傳入的帳密並回傳基本資料回Windows Form。
 
 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net;

using System.IO;

 

namespace CallCRMAuth

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            string url = "http://192.168.1.1/CheckUser.aspx?Account=test001&Password=123456";

            string getdata = "";

            HttpWebRequest MyHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);

            HttpWebResponse MyHttpWebResponse = (HttpWebResponse)MyHttpWebRequest.GetResponse();

            Stream MyStream = MyHttpWebResponse.GetResponseStream();

            StreamReader MyStreamReader = new StreamReader(MyStream, Encoding.GetEncoding("UTF-8"));

            getdata = MyStreamReader.ReadToEnd();

 

            MyStreamReader.Close();

            MyStream.Close();

 

            MessageBox.Show(getdata.ToString());

        }

    }

}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 adamschen9921 的頭像
    adamschen9921

    昶達的部落格

    adamschen9921 發表在 痞客邦 留言(0) 人氣()