N
nganapat
I am trying to post form values to a https web page programmatically
using Httpwebrequest but no matter what I do the same login page is
returned instead of the next page. I would very much appreciate if
someone could show me what is it that I am doing wrong. Below is the
code that I am using.
string viewstate = HttpUtility.UrlEncode(viewstatevalue);
StringBuilder data = new StringBuilder();
data.Append("VAM_Group=");
data.Append("&__VIEWSTATE=" + viewstate);
data.Append("&ctlSignon:txtUserID=userid");
data.Append("&ctlSignon:txtPassword=password");
data.Append("&ctlSignon:ddlSignonDestination=");
data.Append("&ctlSignon:chkMakeDefaultPage=on");
data.Append("&ctlSignon:btnLogin=Login");
data.Append("&TestJavaScript=OK");
byte[] bBuffer;
bBuffer = Encoding.UTF8.GetBytes(data.ToString());
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://online.texanscu.org/texans/login.aspx");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = bBuffer.Length;
req.Credentials = CredentialCache.DefaultCredentials;
req.KeepAlive = true;
req.CookieContainer = new CookieContainer();
Stream swOut = req.GetRequestStream();
swOut.Write(bBuffer,0,bBuffer.Length);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream sr = resp.GetResponseStream();
string result = new StreamReader(sr).ReadToEnd();
return result;
using Httpwebrequest but no matter what I do the same login page is
returned instead of the next page. I would very much appreciate if
someone could show me what is it that I am doing wrong. Below is the
code that I am using.
string viewstate = HttpUtility.UrlEncode(viewstatevalue);
StringBuilder data = new StringBuilder();
data.Append("VAM_Group=");
data.Append("&__VIEWSTATE=" + viewstate);
data.Append("&ctlSignon:txtUserID=userid");
data.Append("&ctlSignon:txtPassword=password");
data.Append("&ctlSignon:ddlSignonDestination=");
data.Append("&ctlSignon:chkMakeDefaultPage=on");
data.Append("&ctlSignon:btnLogin=Login");
data.Append("&TestJavaScript=OK");
byte[] bBuffer;
bBuffer = Encoding.UTF8.GetBytes(data.ToString());
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://online.texanscu.org/texans/login.aspx");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = bBuffer.Length;
req.Credentials = CredentialCache.DefaultCredentials;
req.KeepAlive = true;
req.CookieContainer = new CookieContainer();
Stream swOut = req.GetRequestStream();
swOut.Write(bBuffer,0,bBuffer.Length);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream sr = resp.GetResponseStream();
string result = new StreamReader(sr).ReadToEnd();
return result;