2014-09-10 14:51:06
  httprequest.Headers.Add("Accept-Encoding", "gzip,deflate");
                httprequest.Accept = "text/html, */*; q=0.01";
                httprequest.Headers.Add("Accept-Language", "vi,fr;q=0.8,en-US;q=0.6,en;q=0.4");
                httprequest.Referer ="http://m.thuvienphapluat.vn/Member?ReturnUrl=http://m.thuvienphapluat.vn";
                httprequest.Headers.Add("X-Requested-With", "XMLHttpRequest");
                httprequest.AllowAutoRedirect = true;
                //httprequest.Headers.Add("Proxy-Connection", "keep-alive");
                httprequest.Method = "POST";

This is the pop-up flow.

[close]

 class ThuVienPhapLuatLogin
    {
        static void Main(string[] args)
        {
            HttpPostParam[] httpparams = {
                                new HttpPostParam("UserName", "lif3vil"),
                                new HttpPostParam("Password", "cuchichchim"),
                                new HttpPostParam("submit","submit-value"), 
                             };
            string response = PostTrivialData(new Uri("http://m.thuvienphapluat.vn/Member?ReturnUrl=http://m.thuvienphapluat.vn"), httpparams);
        }
 
        private struct HttpPostParam
        {
            private string _key;
            private string _value;
 
            public string Key { get { return HttpUtility.UrlEncode(this._key); } set { this._key = value; } }
            public string Value { get { return HttpUtility.UrlEncode(this._value); } set { this._value = value; } }
 
            public HttpPostParam(string key, string value)
            {
                this._key = key;
                this._value = value;
            }
        };
 
        private static string PostTrivialData(Uri page, HttpPostParam[] parameters)
        {
            string pageResponse = string.Empty;
            try
            {
                var request = (HttpWebRequest)WebRequest.Create(page); //create the initial request.
                request.UserAgent =
                    "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36";
                request.Method = WebRequestMethods.Http.Post; //set the method
                request.AllowAutoRedirect = true; //couple of settings I personally prefer.
                request.KeepAlive = true;
                request.ContentType = "application/x-www-form-urlencoded";
                request.Referer = "http://m.thuvienphapluat.vn/Member?ReturnUrl=http://m.thuvienphapluat.vn";
                request.CookieContainer = new CookieContainer();
 
                //create the post data.
                byte[] bData = Encoding.UTF8.GetBytes(string.Join("&", Array.ConvertAll(parameters, kvp => string.Format("{0}={1}", kvp.Key, kvp.Value))));
                using (var reqStream = request.GetRequestStream())
                    reqStream.Write(bData, 0, bData.Length); //write the data to the request.
 
                using (var response = (HttpWebResponse)request.GetResponse()) //attempt to get the response.
                    if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.NotModified) //check for a valid status (should only return 200 if successful)
                        using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                            pageResponse = reader.ReadToEnd();
            }
            catch (Exception e)
            {
                /* todo: any error handling, for my use case failing gracefully was all that was needed. */
            }
            return pageResponse;
        }
    }

This is the pop-up flow.

[close]

http://thuvienphapluat.vn/archive/Quyet-dinh-863-LN-QD-che-do-chung-tu-so-sach-ke-toan-trong-don-vi-thuoc-tong-cuc-Lam-nghiep-vb19951.aspx
Invalid Email or Password