Auto login by using HttpWebRequest
===

I'm writing a window application by C# to auto login & post topic to a website. I've tried to pass username & password as the method following but the responseText did not changed. I meant if I passed the incorrect username or password the responseText would be included the "Error text such: wrong password or username" or if I passed to right username & password the responseText would be included "Login successfully" but the responseText I received was like a original login page

Do you have any idea? Thank you so much


        private string Login()
        {
            HttpWebRequest request;

            CookieContainer cookieContainer = new CookieContainer();

            string cookieHeader = string.Empty;

            byte[] byteArray = Encoding.UTF8.GetBytes("username=abc@gmail.com&password=123");

            request = (HttpWebRequest)WebRequest.Create("http://www.vietnamworks.com/dang-nhap");

            request.ContentType = "application/x-www-form-urlencoded";

            request.UserAgent = userAgent;

            request.Method = "POST";

            request.CookieContainer = cookieContainer;

            request.ContentLength = byteArray.Length;

            using (Stream os = request.GetRequestStream())
            {
                os.Write(byteArray, 0, byteArray.Length);
            }

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            string pageSource;

            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                pageSource = sr.ReadToEnd();
            }

            return pageSource;
        }
