日期:2014-05-18 浏览次数:20747 次
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SSLWeb { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string user_name=Request.QueryString["user_name"]; string password = Request.QueryString["password"]; if (user_name == "admin" && password == "admin") { Response.Write("OK"); } else { Response.Write("Error"); } } } }
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Configuration; using System.Security.Cryptography.X509Certificates; using System.Security.Authentication; using System.Net; using System.Net.Security; using System.Windows.Forms; namespace SSLWindows { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { try { string loginUrl = "https://192.168.0.62/Default.aspx"; string userName = "admin";//重点这里传递任何值返回值都是一样的 string password = "admin"; 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); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Security; using System.IO; using System.Security.Cryptography.X509Certificates; namespace SSLWindows { public class HttpWebResponseUtility { private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; " +".NET CLR 1.1.4322; .NET CLR 2.0.50727)"; /// <summary> /// 创建POST方式的HTTP请求 /// </summary> /// <param name="url">请求的URL</param> /// <param name="parameters">随同请求POST的参数名称及参数值字典</param> /// <param name="timeout">请求的超时时间</param> /// <