日期:2014-05-18 浏览次数:20453 次
namespace SSLWeb { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string user_name = Request.QueryString["user_name"]; string password = Request.QueryString["password"]; StreamWriter writer = new StreamWriter("D:\\test.txt"); writer.WriteLine("user_name:" + user_name); writer.WriteLine("password:" + password); writer.WriteLine("Time:" + System.DateTime.Now); if (user_name == "admin" && password == "admin") { writer.WriteLine("OK"); Response.Write("OK"); } else { writer.WriteLine("Error"); Response.Write("Error"); } writer.WriteLine("--------------------------------"); writer.Close(); } } } }
namespace SSLWindows { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { try { #region Get方法 string userName = "1"; string password = "1"; string tagUrl = "https://192.168.0.62/Default.aspx?user_name="+userName+"&password="+password; CookieCollection cookies = new CookieCollection(); HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(tagUrl, null, null, cookies); string cookieString = response.StatusDescription; if (cookieString == null) { MessageBox.Show("null"); } else { MessageBox.Show(cookieString); } #endregion #region Post方法 //string loginUrl = "https://192.168.0.62/Default.aspx"; //string userName = "1"; //string password = "1"; //Encoding encoding = Encoding.GetEncoding("gb2312"); //IDictionary<string, string> parameters = new Dictionary<string, string>(); //parameters.Add("@user_name", userName); //parameters.Add("@password", password); //HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(loginUrl, // parameters, null,null, encoding,null); ////StreamReader re = new StreamReader(request.GetResponse().GetResponseStream()); //string cookieString = response.StatusDescription; //if (cookieString == null) //{ // MessageBox.Show("null"); //} //else //{ // MessageBox.Show(cookieString); //} #endregion } ca